trouble with SKStoreProductViewController and MPMediaLibraryDidChangeNotification

My app uses Apple Music Search to find song and then uses SKStoreProductViewController to let users them buy.


On my test device I correctly see the SKStoreProductViewController how ever I can not seem to actually purchase anything. I see the "buy circle" spin. my productViewControllerDidFinish: delegate is called how ever I never recieve MPMediaLibraryDidChangeNotification


I check my purchase history on my mac using iTunes, and on my test devices. Seems like they do not get purchased or downloaded?


Here is my notification registration code

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mediaLibraryDidChangeNotification:)
                                                 name: MPMediaLibraryDidChangeNotification
                                               object:nil];
    [[MPMediaLibrary defaultMediaLibrary] beginGeneratingLibraryChangeNotifications];


I would like to know when/if the purchase was completed and when/if the song was downloaded


based on other threads I think the issue might be that SKStoreProductViewController might be disabled when you are working in your development or testFlight enviroment. Is that true? If so any idea how I can test my code with out releasing it first?


Kind regards


Andy

Replies

In this past thread, an Apple employee says that a test app (even when downloaded via TestFlight) uses the sandbox and cannot purchase items from SKStoreProductViewController. There is apparently no direct way to test if SKStoreProductViewController works, which I have also found to be frustrating.


If I remember correctly, I simulated the workflow by syncing a song via iTunes (to test MPMediaLibraryDidChangeNotification) while the SKStoreProductViewController is visible. I was eventually able to use this in a production app (and have been successfully using this functionality for over a year now).