1

We are using MPMusicController in order to play short sound, but from iOS 13.4 onwards the application started crashing due to missing NSAppleMusicUsageDescription key in the info.plist.

However, after adding the key in info.plist, play/pause API of MPMusicController triggers the "Apple Music Permission". Now, accepting or denying permission does not impact the sound playing through MPMusicController, which makes me wonder.

Ideally, it should not function when the permission is denied, I would appreciate it if anyone has an idea or explanation on this?

Aman.Samghani
  • 2,151
  • 3
  • 12
  • 27

1 Answers1

-1

check apple music permission

 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
    }
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103