【发布时间】:2019-04-17 05:47:47
【问题描述】:
在更新我的应用程序以支持后台应用程序刷新时,我遇到了 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]:错误域=NSPOSIXErrorDomain Code=53 "软件导致连接中止" UserInfo={NSErrorFailingURLStringKey=https://www.example.com/orders, _kCFStreamErrorDomainKey=1,NSErrorPeerAddressKey={长度=16,容量=16,字节= 0x100201bb3e80187c0000000000000000},_kCFStreamErrorCodeKey=53, NSErrorFailingURLKey=https://www.example.com/orders}
【问题讨论】:
-
你的应用支持
fetch后台模式吗? -
@mag_zbc 是的,后台获取功能已打开,即使
performFetchWithCompletionHandler正在被调用。
标签: ios afnetworking afnetworking-2 ios12 afhttprequestoperation