2

As part of an app I am developing, I need to know when the user changes a track. It isn't possible to use AVPlayer with DRM tracks, so Apple Music is out of the question with that method.

If I register for MPMusicPlayerControllerNowPlayingItemDidChangeNotification, the notifications only come through while the app is active (of course), and when I resume the app only the last song's notification is sent.

Is there an Apple approved method to get this data? Basically, if a user closes my app, listens to 10 songs, and then opens my app again, I want to know which songs he/she listened to and how long he listened to each song for.

Since I will also be tracking location (although I only need geofence type tracking) I was considering using this method to keep the app active. (Though I don't know how it would tie in with receiving NowPlaying change notifications -- any guidance here would be appreciated too)

Community
  • 1
  • 1
kolossal7
  • 155
  • 3
  • 9

0 Answers0