交易如下:
我正在编写一个应用程序,可以播放用户库中的音乐。我正在使用MP授权方法,如下所示:
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")
}
}
}
等等在播放任何存储的URI之前,我还会检查授权状态,以防用户改变主意。
一旦我授予(或拒绝)授权,系统就会记住我的应用程序,以后再也不会有人问我了。即使卸载应用程序并重新安装,也只会重新唤醒隐私面板中的开关。
这给了我两个问题:
1) 我做得对吗,上面?