我在初始化后台NSURLSessions时遇到问题而没有阻止进程并最终将错误日志丢弃到控制台上。我的代码就像这样布局了
NSURLSessionConfiguration * configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:@"Something.something"];
configuration.sharedContainerIdentifier = @"group.Something.something.else"
self.operationQueue = [[NSOperationQueue alloc] init];
self.operationQueue.maxConcurrentOperationCount = 1;
self.session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:self.operationQueue];
初始化后,它会阻止进程,30秒后会生成此错误日志
2017-12-08 15:14:29.778309-0500 LibraryManagerTestExtension[1828:1032535] failed to open connection to AppleKeyStore
2017-12-08 15:14:29.778489-0500 LibraryManagerTestExtension[1828:1032535] Unexpected AppleKeyStore error: -536870212
2017-12-08 15:14:29.778844-0500 LibraryManagerTestExtension[1828:1032535] MKBDeviceUnlockedSinceBoot: MKBDeviceUnlockedSinceBoot fails with error(-1) for handle(0) with AKS error(-536870212)
2017-12-08 15:14:29.778915-0500 LibraryManagerTestExtension[1828:1032535] Attempting to create a background session before first device unlock!
2017-12-08 15:14:29.782429-0500 LibraryManagerTestExtension[1828:1032603] An error occurred on the xpc connection: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.nsurlsessiond was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.nsurlsessiond was invalidated.}
这是我的Info.plist设置
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>RequestOpenAccess</key>
<true/>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<string>5</string>
</dict>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.app.non-ui-extension</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).LibraryManagerTestExtension</string>
</dict>
知道如何不做到这一点吗?
答案 0 :(得分:0)
我看到您将NSExtensionPointIdentifier
设置为com.apple.app.non-ui-extension
。这是一个私人标识符,并且具有受限制的权限,阻止您执行此操作。
我建议您将NSExtensionPointIdentifier
更改为com.apple.services
(非UI操作),然后应该允许您执行这些操作的权限。