Not authorized, skipping filter predicate application
Asked Answered
L

1

5

Upon launch on an iOS10 device, I get the following output:

[MC] Reading from public effective user settings.

[SDKPlayback] MPMusicPlayerController] MPMusicPlayerController: Server is not running, deferring check-in

[SDKLibrary] Not authorized, skipping filter predicate application

The app plays music from the user's library and therefore must ask permission, so I have updated info.plist with the required key strings for NSAppleMusicUsageDescription but the app crashes as soon as the predicate is called. When the app is stopped and the launch screen disappears, the permission window is finally displayed. If I tap allow, subsequent launches will work just fine.

My question is: Does the "server not running" error have anything to do with the permissions window not being shown? If so, how do I start it?

Luau answered 20/11, 2016 at 21:3 Comment(2)
The output mentioned above is produced when running on a device (iPhone 6s+), not in the simulator.Luau
Also, this is a systemMusicPlayer, not an applicationMusicPlayer.Luau
G
10

So, the way an MPMusicPlayerController works is:

  1. You have to have the key in the Info.plist, as you already know.

  2. In your code, check authorization with MPMediaLibrary.authorizationStatus.

  3. If you don't have authorization, you request authorization using MPMediaLibrary.requestAuthorization. You cannot proceed until you have authorization. Be careful because the call is asynchronous and the completion is called on a background thread.

  4. Now you make an MPMediaItemCollection and call setQueue(with:) and then play.

Gentilis answered 20/11, 2016 at 22:51 Comment(2)
This is what I was missing. I'm leaving this comment since I don't have the reputation needed to mark an answer.Luau
@matt: Thank you for the support. How can I play a particular song from the list.Sternway

© 2022 - 2024 — McMap. All rights reserved.