Search code examples
iosswiftmedia-player

How Can I Make the iPhone/iPad Completely Forget Media Authorization Status for an App?


Here's the deal:

i'm writing an app that plays music from the user's library. I'm using the MP authorization methods, like so:

        if .authorized == MPMediaLibrary.authorizationStatus() {    // Already authorized? Head on in!
            if inDisplayWholeScreenThrobber {
                self._showLargeLookupThrobber()
            }
            if let songItems: [MPMediaItemCollection] = MPMediaQuery.songs().collections {
                self._loadSongData(songItems)
                self._selectSong()
                self._hideLargeLookupThrobber()
            }
        } else {    // Can I see your ID, sir?
            MPMediaLibrary.requestAuthorization { [unowned self] status in
                switch status {
                case.authorized:
                    if inDisplayWholeScreenThrobber {
                        self._showLargeLookupThrobber()
                    }
                    if let songItems: [MPMediaItemCollection] = MPMediaQuery.songs().collections {
                        self._loadSongData(songItems)
                        self._selectSong()
                        self._hideLargeLookupThrobber()
                    }

                default:
                    TheBestClockAppDelegate.reportError(heading: "ERROR_HEADER_MEDIA", text: "ERROR_TEXT_MEDIA_PERMISSION_DENIED")
                }
            }
        }

and so on. I also check authorization status before playing any stored URI, just in case the user changed their mind.

Here's the problem:

Once I grant (or deny) authorization, the system remembers my app, and I'll never be asked again. Even uninstalling the app and reinstalling it just reawakens the switch in the Privacy panel.

The only way that I can get it to forget me, is to change the app Bundle ID.

This gives me 2 questions:

1) Am I doing it right, above?

2) How can I force the system to forget my app ever existed?


Solution

  • OK. I figured one way to do it. Annoying, but it works.

    If you delete the app, then shut down and restart the device, the status resets.