@koodos/apple-music-capacitor-plugin
v0.0.2
Published
Apple Music
Downloads
7
Readme
apple-music
This plugin integrates Swift's MusicKit framework (available on iOS 15.0+), to retrieve the Apple Music developer token and user token.
Setup
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.
Install
npm install apple-music
npx cap sync
Usage
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.
API
isAuthorized()
isAuthorized() => any
Returns: any
hasMusicSubscription()
hasMusicSubscription() => any
Returns: any
authorize()
authorize() => any
Returns: any
unauthorize()
unauthorize() => any
Returns: any
getDeveloperToken(...)
getDeveloperToken(data?: { ignoreCache?: boolean | undefined; } | undefined) => any
| Param | Type |
| ---------- | --------------------------------------- |
| data
| { ignoreCache?: boolean; } |
Returns: any
getUserToken(...)
getUserToken(data: { developerToken: string; ignoreCache?: boolean; }) => any
| Param | Type |
| ---------- | --------------------------------------------------------------- |
| data
| { developerToken: string; ignoreCache?: boolean; } |
Returns: any