This plugin integrates Swift's MusicKit framework (available on iOS 15.0+), to retrieve the Apple Music developer token and user token.
-
Add
NSAppleMusicUsageDescription
to yourInfo.plist
, describing why your app needs access to the user's Apple Music account. -
Follow this guide to enable MusicKit App Service for your App ID, in the Apple Developer Portal.
npm install apple-music
npx cap sync
Refer to the API documentation below.
For standard usage:
- Call
authorize()
to request authorization from the user. - Call
hasMusicSubscription()
to check if the user has an active Apple Music subscription. - Call
getDeveloperToken()
to retrieve the developer token. UseignoreCache: true
if you're unsure if the cached token is still valid. - Call
getUserToken()
to retrieve the user token, providing thedeveloperToken
argument. UseignoreCache: true
if you're unsure if the cached token is still valid.
isAuthorized()
hasMusicSubscription()
authorize()
unauthorize()
getDeveloperToken(...)
getUserToken(...)
isAuthorized() => any
Returns: any
hasMusicSubscription() => any
Returns: any
authorize() => any
Returns: any
unauthorize() => any
Returns: any
getDeveloperToken(data?: { ignoreCache?: boolean | undefined; } | undefined) => any
Param | Type |
---|---|
data |
{ ignoreCache?: boolean; } |
Returns: any
getUserToken(data: { developerToken: string; ignoreCache?: boolean; }) => any
Param | Type |
---|---|
data |
{ developerToken: string; ignoreCache?: boolean; } |
Returns: any