Contents

Offering Apple Music Subscription in Your App

Allow eligible customers to subscribe to Apple Music.

Overview

With an Apple Music membership, customers can play songs from the entire Apple Music catalog or access their iCloud music library across all their devices. You can offer users the option to sign up for an Apple Music subscription directly from your app by following these steps:

  1. Request Apple Music Library access from the customer.

  2. Determine if the customer is eligible for an Apple Music subscription.

  3. Present the sign-up subscription offer if the customer is eligible.

Request Apple Music Library Access

The user must grant permission before your app can access Apple Music library. See Requesting Access to Apple Music Library for details. Use authorizationStatus() to determine your app’s authorization status. If the authorization status is SKCloudServiceAuthorizationStatus.authorized, your app can check if the user is eligible for an Apple Music subscription offer.

Determine if the User is Eligible for an Apple Music Subscription

After getting Apple Music access from the user, call requestCapabilities(completionHandler:) on an instance of SKCloudServiceController to query the user’s capabilities. Then, inspect the capabilities parameter of this method to determine eligibility. See Determining a person’s Apple Music capabilities for details. A user has an active subscription to Apple Music when capabilities contains musicCatalogPlayback. A user is eligible for the offer when capabilities doesn’t include musicCatalogPlayback but contains musicCatalogSubscriptionEligible.

Present the Offer to Subscribe for Apple Music

For users who are eligible for an Apple Music subscription, use the following steps to allow users to sign up for it.

First, create a dictionary with an action key to subscribe:

If you have an iTunes Store affiliate account, you can add the affiliateToken key to the dictionary to earn commision if the user subscribes:

By default, the setup view is configured with the messageIdentifier key set to join. Add messageIdentifier to the dictionary and set it to addMusic, connect, or playMusic if you wish to change the default message that your app shows to the user:

Next, create an SKCloudServiceSetupViewController object and set the view controller class as its delegate:

Then, pass the dictionary to the load(options:completionHandler:) method of the SKCloudServiceSetupViewController object. Finally, present the SKCloudServiceSetupViewController object modally from your app:

See Also

Loading the setup view