我在 crashlytics 上遇到以下崩溃,我无法在我的设备上重现
Fatal Exception: NSGenericException
Task created in a session that has been invalidated
在以下行
NSURLSessionTask *task = [self.session uploadTaskWithRequest:request fromFile:filePathURL];
[task resume];
[self.session finishTasksAndInvalidate];
我在委托方法中处理了会话失效
- (void)URLSession:(NSURLSession *)session didBecomeInvalidWithError:(NSError *)error {
// Crashlytics logging
[CrashlyticsKit setBoolValue:true forKey:@"URLSession_didBecomeInvalid"];
self.session = [self createNewSession];
}
- (NSURLSession *)CreateSession {
NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:SERVER_URL];
if (@available(iOS 11.0, *)) {
sessionConfig.waitsForConnectivity = YES;
}
return [NSURLSession sessionWithConfiguration:sessionConfig delegate:self delegateQueue:nil];
}
上传新版本后,我仍然遇到同样的崩溃,并且“ didBecomeInvalidWithError
”处根本没有 Crashlytics 日志!
知道如何解决这个崩溃吗?