Error using SKCloudServiceController API to check

2019-08-24 10:31发布

问题:

I am using this code to try to check a devices Apple Music capabilities:

  SKCloudServiceController *controller = [SKCloudServiceController new];
  [controller requestCapabilitiesWithCompletionHandler:^(SKCloudServiceCapability capabilities, NSError * _Nullable error) {
    if (error != nil) {
      NSLog(@"Error getting SKCloudServiceController capabilities: %@", error);
    } else if (capabilities & SKCloudServiceCapabilityMusicCatalogPlayback) {
      NSLog(@"YES SUBSCRIBED!!!!");
    } else {
      NSLog(@"NOT SUBSCRIBED!!!!");
    }
  }];

Unfortunately, I can not track down how to fix the errors I am receiving.

I assume that SKCloudServiceController is finding out the device capabilities locally and should not need to connect to Apple to determine this.

So why do the errors lead me to believe that SKCloudServiceController is having some sort of communications problem connecting to Apple?

Here is the time stripped output log showing the errors:

[core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
[core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
SSAccountStore: Unable to get the local account. error = Error Domain=SSErrorDomain Code=100 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}
Error getting SKCloudServiceController capabilities: Error Domain=SKErrorDomain Code=6 "The requesting app does not have the necessary permissions" UserInfo={NSLocalizedDescription=The requesting app does not have the necessary permissions}
warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.
(lldb) 

Thanks for any help on this :)

P.S. I did remember to add StoreKit capabilities to my project and imported its header file in the .m file where I run my code from.