alfioal alfioal - 1 year ago 121
Objective-C Question

Apple Music detect is member

In iOS 9.3 Apple release new APIs. Now developers can see if a user is currently a member of Apple Music. I'm trying to understand how it works.
My code -only first time- asks the user whether to access the music library but I don't understand how to determine in what ways you can detect if user is a member and open Apple Music to join it. These actions in Shazam works really great. How can I do something like that?
Thanks in advance!

[SKCloudServiceController requestAuthorization:^(SKCloudServiceAuthorizationStatus status) {

NSLog(@"status is %ld", (long)status);

SKCloudServiceController *cloudServiceController = [[SKCloudServiceController alloc] init];

[cloudServiceController requestCapabilitiesWithCompletionHandler:^(SKCloudServiceCapability capabilities, NSError * _Nullable error) {

NSLog(@"%lu %@", (unsigned long)capabilities, error);

if (capabilities >= SKCloudServiceCapabilityAddToCloudMusicLibrary || capabilities==SKCloudServiceCapabilityMusicCatalogPlayback) {

NSLog(@"You CAN add to iCloud!");

} else {

NSLog(@"The ability to add Apple Music track is not there. sigh.");



Answer Source

As far as I know, you can't directly check if they are a member. You can check the following:

[SKCloudServiceController authorizationStatus];

If the result is 'authorized' then they are a member. If it is 'notDetermined' then you need to call the requestAuthorization method. If it's denied they may not be a member or they might've just denied your app's access to their music library.

That's just my understanding, based off of the available documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download