Sarfraz Sarfraz - 3 years ago 115
Objective-C Question

Passing MPMediaItemPropertyPersistentID from Objective C to JavaScript from Cordova Plugin

I am basically building a cordova plugin for Apple Music. The plugin gets the list of playlists, Gets songs for a particular playlist and plays songs from a particular play list.
I need to save the MPMediaItemPropertyPersistentID of a playlist and pass it from the plugin written in Objective C to the JavaScript, where the app is being built using cordova.
The [Item valueForProperty:MPMediaItemPropertyPersistentID] return an unsigned long long, which I am saving as NSNumber*. When I pass it to Java script, it's value is found to be different.

Answer Source

I figured the answer to this. The MPMediaItemPropertyPersistentID which is received in NSNumber format has to be converted into NSString and then passed to the plugin. Following is how we get the value and how we can convert it.

NSNumber * PlaylistID= [playlist valueForProperty: MPMediaPlaylistPropertyPersistentID];

NSString *numStr = [NSString stringWithFormat:@"%lld", [PlaylistID unsignedLongLongValue]];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download