No songs detected on iPad

2019-08-04 04:16发布

问题:

My app has been rejected by Apple :( The issue reported is

The application does not detect the songs on the iPad.

I already tried to have all the tests I can in order to understand the issue, but on MY ipad and on MY songs, everything works 100% fine.

In my code I'm handling the situation of an empty library in the following way:

MPMediaQuery *albums = [MPMediaQuery albumsQuery];
NSArray *albumCollections = [albums collections];
if ([albumCollections count] > 0) {
    // everything fine, let's start
}
else {
    // display an UIAlertView warning the user that the library is empty and stop
}

Now Apple just sent me a screenshot to display that the UIAlertView it's always showing up, even if they state they have songs on the iPad.

What can be the issue? Can maybe albumCollections be empty even if there are songs on the device? Any help is greatly appreciated, I put lot of effort in the app and seeing it rejected for a reason I'm not able to reproduce is so frustrating :(

回答1:

What you learn from your code is that there are no MPMediaItemCollections (i.e. no albums). That is not the same as claiming that there are no songs.



回答2:

check this code

MPMediaQuery *everything = [[MPMediaQuery alloc] init];

NSLog(@"Logging items from a generic query...");

NSArray *itemsFromGenericQuery = [everything items];// get all media content

for (MPMediaItem *song in itemsFromGenericQuery) {

   NSString *songTitle = [song valueForProperty: MPMediaItemPropertyTitle];

   NSLog (@"%@", songTitle);

}

reference link --ipad library access programming