1

我们使用 MPMusicController 来播放短声音,但从 iOS 13.4 开始,由于 info.plist 中缺少NSAppleMusicUsageDescription键,应用程序开始崩溃。

但是,在 info.plist 中添加密钥后,MPMusicController 的播放/暂停 API 会触发“Apple Music Permission”。现在,接受或拒绝许可不会影响通过 MPMusicController 播放的声音,这让我感到奇怪。

理想情况下,当权限被拒绝时它不应该起作用,如果有人对此有想法或解释,我将不胜感激?

4

1 回答 1

-1

检查苹果音乐许可

 func appleMusicRequestPermission() -> Bool{

        var isAllowAccess: Bool = false

        switch SKCloudServiceController.authorizationStatus(){

        case .notDetermined:

            print("The user hasn't decided yet - so we'll break out of the switch and ask them.")
            let allow = self.askAppleMusicPermissio()
            isAllowAccess = allow
            break
        case .denied:
            print("The user has selected 'Don't Allow' in the past - so we're going to show them a different dialog to push them through to their Settings page and change their mind, and exit the function early.")
            isAllowAccess = false
            break
        case .restricted:
            print("User may be restricted; for example, if the device is in Education mode, it limits external Apple Music usage. This is similar behavior to Denied.")
            isAllowAccess = false

            break

        case .authorized:

            print("The user's already authorized - we don't need to do anything more here, so we'll exit early.")

            isAllowAccess = true
    
            break

        default:

            isAllowAccess = false
            break
        }

        return isAllowAccess
    }
于 2021-03-16T04:25:23.967 回答