Music Kit Authorize without Subscription

I'm working on a streaming application using Music Kit. For the login, I'm using the "authorize" method which works fine when I use an account that has an Apple Music subscription. When I use an account that does not have a subscription I get prompted to try out Apple Music:

If I click "not now" it doesn't return anything at all from what I see and it just stops my function altogether. This is the code I have setup to test this:

const appleLogin = async () => {
  console.log("Apple Login Called");
  const userToken = await appleMusicInstance.value.authorize();

  console.log("user token", userToken);
};

When I log in using a subscription account it works fine, I get a token and I can stream full-length songs. When I click "not now" (with a non-subscription account) it just stops. Doesn't even show that my "userToken" received anything and nothing else in the function gets called.

I'd like to have the ability for members to log in with their account whether they have a subscription or not and play either full length or previews based on their subscription status.

What would be the best solution to this?

Replies

Thank you for the question, @gonzosan

The authorization flow is only expected to resolve with a valid user token if the user logs in, authorizes your app, and has a valid Apple Music subscription. Without the user having a valid subscription, your app would not be able to differentiate logged in users from logged out users.

You can use the previewOnly Boolean flag on the MusicKit instance to determine if full playback is available or only previews.

The behavior you described where your method hangs after the user chooses "Not Now" is not expected. It would be very helpful if you could file a ticket in the Feedback Assistant so that we can keep you informed as we diagnose the issue.