在更新我的应用程序以支持后台应用程序刷新时,我遇到了 AFNetworking 的问题。
我越来越NSPOSIXErrorDomain Code=53 "Software caused connection abort"
。该问题似乎出现在 iOS 12 中,后台连接被终止。
AFNetworking 2.6.3 用于进行提取。
AppDelegate.m
:
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[OrdersService performFetch];
completionHandler(UIBackgroundFetchResultNewData);
}
OrdersService.m
:
-(void) performFetch {
[[AFHTTPRequestOperationManager new] GET:@"https://www.example.com/orders"
parameters:nil
success:^(AFHTTPRequestOperation *operation, id responseObject) {
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}
];
}
控制台输出:
[错误] GET '(null)' (0) [31.9163 s]: Error Domain=NSPOSIXErrorDomain Code=53 "软件导致连接中止" UserInfo={NSErrorFailingURLStringKey= https://www.example.com/orders , _kCFStreamErrorDomainKey=1 , NSErrorPeerAddressKey={长度 = 16, 容量 = 16, 字节 = 0x100201bb3e80187c0000000000000000}, _kCFStreamErrorCodeKey=53, NSErrorFailingURLKey= https://www.example.com/orders }