1

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 :(

Sr.Richie
  • 5,680
  • 5
  • 38
  • 62

2 Answers2

2

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.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • could you point me to a RIGHT method to check if the library is empty or not? I don't need any kind of grouping or sorting at that point, just need to check if the app can run – Sr.Richie Feb 04 '14 at 18:21
  • Well, how about doing a `songsQuery`? Even better, a generic (ungrouped, unfiltered) query? Even better, how about just failing more gracefully? If your app depends upon the presence of albums (mine does), then if there are none, just show an empty interface - without the alert. That is certainly not the same as claiming (perhaps wrongly) that the library is empty. – matt Feb 04 '14 at 18:36
  • first of all thank for you support. You're guiding me towards the resolution of the problem. However I'm now facing a collateral problem. If I do a generic songsQuery the problem is half solved, because the songs are then sorted by alphabetic title and not by album. How could I sort the songs by album if available? Imagine a library of 10 songs: 5 without album info, 5 belonging to the same album... – Sr.Richie Feb 06 '14 at 16:21
  • @Sr.Richie Ask a separate question please; do not use comments to piggyback a new question onto a previous answered question. Feel free to link to the new question in a comment here, though! – matt Feb 06 '14 at 16:39
  • here you are. Thx a lot man http://stackoverflow.com/questions/21609105/sorting-an-array-of-songs-by-album-when-album-info-available – Sr.Richie Feb 06 '14 at 16:54
1

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

Pawan Rai
  • 3,434
  • 4
  • 32
  • 42