When sharing playlist in Apple Music app via Email, you can get a URL like this
https://itunes.apple.com/jp/playlist/if-you-like...may-j./idpl.4299b4c5a42048bd850eca538e68ace2?l=en
You will also have an URL when sharing local created playlist.
I would like to know if it is possible to get the URL programmatically on iOS using Swift.
[Effort studied but failed to solve]
Related discussion using link maker does not solve the problem
Apple Music URL Scheme
Query the playlist using: MPMediaQuery.playlists() and enumerated the returned playlist but cannot find any property showing the URL
I'm pretty sure this is not possible. I believe the playlist does not have the idpl value until the user manually presses the share button in iTunes. And, there's nothing in the API to create one.
I set up a proxy and had a look at the requests iTunes makes.
I created a playlist in iTunes and added songs to the playlist. Every song I added made several requests to various endpoints under:
https://ld-6.itunes.apple.com/WebObjects/MZDaap.woa/daap/update No idpl value in any of the responses.
Then I manually hit the share button. A request is made to
https://client-api.itunes.apple.com/WebObjects/MZStorePlatform.woa/wa/lookup with the idpl in the URL.
Now when you add more songs to the playlist, the responses contain the idpl.
From that it seems that the idpl is created on the device when the user touches share.
Probably best to file a radar for Apple to add a share URL property to MPMediaPlaylist.
EDIT: I filed a radar
Related
Following this question we can get a JSON response from the iTunes Search API to direct users to the trackViewUrl. The answer suggested appending &app=itunes to have the iOS device open the URL in the iTunes Store instead of Apple Music, but my test suggests that this doesn't work and Apple Music is still opened.
For instance, the first item of the result of:
https://itunes.apple.com/search?term=pink+floyd%20high%20hopes
shows a trackViewUrl of:
https://music.apple.com/us/album/high-hopes/1067444712?i=1067444898&uo=4,
with the appended request is:
https://music.apple.com/us/album/high-hopes/1067444712?i=1067444898&uo=4&app=itunes
However, this link opens Apple Music on an iOS device.
Is there a way to open the iTunes Store instead? Or another way to open the iTunes Store to a specific track? I need DRM free tracks.
The correct way of doing this now is with StoreKit.
I have recently been using the new Apple MusicKit functionality.
I've got a Developer Token and Music-User-Token and I can run the test code provided by Apple.
I want to try and do a few more things but the documentation doesn't seem to cover it.
From what I can tell (at the moment) the User Token is only used to edit things like ratings of albums, songs etc
Source: https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/AppleMusicWebServicesReference/RateaAlbum.html#//apple_ref/doc/uid/TP40017625-CH78-SW1
Problem 1:
What I'd love to do is create a playlist (via this API rather than the native Objective-C/Swift) code.
Using the native code, the playlist ID is a GUID but this ID doesn't seem to be relevant to the Apple APIs ID for a playlist (formatted pl.u-[uniquereference])
Problem 2:
I'd also like to retrieve a list of my playlists.
Has anyone done this? Is it even possible?
You can download the Apple Music Sample Code here, and take a look function createPlaylistIfNeeded() in MediaLibraryManager.swift. It does create a playlist.
Base on my understanding you can create and retrieve the playlist by using
MPMediaLibrary.getPlaylist(with:creationMetadata:completionHandler:)
However, if you go to check this function's definition on Apple Developer Document
getPlaylist(with:creationMetadata:completionHandler:)
Retrieves an app maintained existing playlist or creates a new
playlist when no playlist exists.
So, I think you can not retrieve users' playlist unless it is created in your app.
Btw, Would you mind to share how you done with the JWT? I checked the website that the Apple provided JWT Website. But the swift library JWT it recommended on the site, has not yet supported ES256. So I had to use a python library to generate one and hardcode in the code for testing.
Please let me know if you have solved it. Thanks
I want to open NAVER's LINE.app from within my iOS app using a URL scheme, and let my user share my iOS app using the preset string and AppStore URL.
I already set LSApplicationQueriesSchemes, and I know how to share a string to friends (using line://msg/text).
But how can I let him post it to the timeline? I even can't get to the documentation page but they clearly said it is feasible in the docs.
User selects who to share the content with. (Content can be shared with friends or posted on the user’s Timeline).
NOTE: I don't want to share it via Activity Controller. I want to use UIButton to trigger the share action.
I'm creating an iOS radio station app, and I can't find a solution to what I thought was a simple problem. If my radio station plays an song/album people want to buy, how can I just launch the iTunes Store and have it open with a search results for that track or album?
I know I can use the Apple Search API to get a json of the search results and parse that for the best search results, and I know I can open the iTunes store with https://itunes.apple.com/ (if I try to append a search string to this, I get the metadata back) or with SKStoreProductViewController if I know the product ID.
But is there a way to simply open the iTunes Store to open with search results for a song or album (or both) without having to evaluate the search metadata and send them to one (perhaps wrong) product?
Thanks!
You can do this using URL Scheme's and a tool called iTunes Link Maker. Documentation can be found for iTunes on Apple's website here
The iTunes URL scheme is used to link to content on the iTunes Music
Store. The iTunes URL format is complicated to construct, so you
create it using an online tool called iTunes Link Maker. The tool
allows you to select a country destination and media type, and then
search by song, album, or artist. After you select the item you want
to link to, it generates the corresponding URL.
http://linkmaker.itunes.apple.com/
I have video and photo sharing working fine in an iOS app using UIActivityViewController.
Now I want to upgrade it so that the app posts a custom OpenGraph story to the timeline. Something like "User posted Video from MySuperApp".
I've got the all the iOS side written, and I've got a Facebook app created and configured in the project, login, etc.
I'm a bit frustrated by the rest of the documentation, though:
The submission guidelines speak about a "user generated photos" permission that doesn't seem to be available anywhere in the app settings, or anywhere else in the documentation. Is that still required? Is there a similar permission for videos?
It says "Photos must be original and can only be those taken with a camera by the person who is publishing them". The app allows adding annotations/drawings on top of a photo. Does that still count as "original"? And I guess the normal image controls allow selecting images from an album, so I have no way to enforce this, do I? (Other than writing a completely custom camera control, I guess...)
The API allows to "stage" a photo for a story. Is it possible to stage a video, or do I need to upload it externally? Can I refer to a video in a user's album in a story?
Is it possible to use FBDialogs to post a story about a video, or do I need to write my own?
Update:
Current status: I wrote my own UIActivity to share on Facebook and my own activity view controller.
Making a custom story about a photo is straightforward, and covered by documentation and examples, but to summarize:
stage photo, returns url
create object, returns id
create action (returns id)
Make sure you set "explicitly_shared" to true, so the action appears in the timeline. It is a good idea to follow their recommendations for error handling as well, otherwise it is a pain to debug.
I am not further with videos, though. Uploading a video is easy ([FBRequest requestForUploadVideo]), but that returns an id. So far I have not been able to use this id in either an object or an action. Querying the graph API for that id doesn't return any information. The video appears on the timeline by itself as well.
I'm tempted to just ditch the custom story about the video.
Update:
Okay, based on the feedback here and on the Facebook group I have to assume that it is not possible to upload and share a video as part of a story. I'm going to strip the feature down to just upload the video to the album.