MusicKit allows access to Apple Music API to search for content
It also allows for playback in third party apps (user needs to be subscribed)
Music items:
Albumwith attributes, relationships and associationsUse
album.with([.artists, .tracks, .relationAlbums])for fetching relationshipsAll calls are using Swift concurrency, so
try awaitneeded on call sitePlayback integrates with system, so media controls in lock screen work for example
Requests done via
MusicCatalogResourceRequest<Album>(matching:equalTo:)Then just call
try await request.response()on the request objectContributor comment: The networking structure here is interesting, maybe a new platform best practice!?
User consent is needed to access music listening history & music library (separately)
Access is given once per device & per app, dialog has “yes” / “no” options
As always, a usage description must be provided in
Info.plistfileUse
MusicAuthorization.request()(async method) to get access inMusicKitAPI token for Apple Music API is automated by Xcode, just check the box in Connect
3 information to check regarding subscription capabilities:
can play catalog content, has cloud library enabled & can become subscriber
MusicSubscription.subscriptionUpdatesinforms app when user subscribesTwo players available,
SystemMusicPlayerintegrates with system more,ApplicationMusicPlayerallows for more customization for the app like playback queueApple Music free trial can be started right within third party apps via system sheet
New Affiliate program to get bonus if users subscribe via 3rd party app
Class supports album customization, named
MusicSubscriptionOffer(.Options)Possible use cases: background music in games, music during workouts, social media
Meet MusicKit for Swift
MusicKit makes it easy to integrate Apple Music into your app. Explore the Swift-based framework: We’ll take you through the basic process of using MusicKit — including how to find, request, and play content — and show you how you can incorporate music subscription workflows into your app if someone hasn’t yet signed up to Apple Music.
Missing anything? Corrections? Contributions are welcome!
Written By

Jeehut