I use addItemWithProductID: in the code below to add an Apple Music track to the user's library. This is mature code that's worked fine previously. But now in iOS 14.0.1 it causes the app to freeze. I can trace when running from Xcode or the released app version from App Store and the app freezes after the line:
NSLog(@"just before addItemWithProductID %@", productID);
The ">>>added..." line is never called.
Any idea as to how to remedy?
NSLog(@"just before addItemWithProductID %@", productID);
The ">>>added..." line is never called.
Any idea as to how to remedy?
Code Block -(void) addAppleMusicTrackWithProductID: (NSString *) productID { NSLog(@" addApplemUsic has been called for productID: %@", productID); SKCloudServiceController *cloudServiceController; cloudServiceController = [[SKCloudServiceController alloc] init]; [cloudServiceController requestCapabilitiesWithCompletionHandler:^(SKCloudServiceCapability capabilities, NSError * _Nullable error){ NSLog(@"capabilities: %lu error:%@", (unsigned long)capabilities, error); if (capabilities >= SKCloudServiceCapabilityAddToCloudMusicLibrary) { NSLog(@"just before addItemWithProductID %@", productID); [[MPMediaLibrary defaultMediaLibrary] addItemWithProductID:productID completionHandler:^(NSArray<__kindof MPMediaEntity *> * _Nonnull entities, NSError * _Nullable error) { NSLog(@">>>added %@ with %i entities: %@ and error %@",productID, (int) entities.count, entities, error); NSArray *tracksToPlay = [NSArray arrayWithObject:productID]; [musicPlayer setQueueWithStoreIDs:tracksToPlay]; [musicPlayer play]; NSLog(@">>>>now playing AM title:%@ | artist:%@", musicPlayer.nowPlayingItem.title, musicPlayer.nowPlayingItem.artist); }]; } }]; }