Authorize to Apple Music via In-App Browser (FB Messanger,Instaram,Twitter))

We're using 
https://developer.apple.com/documentation/musickitjs to authorize Apple music, on Desktop it opens a new window to authorize to apple.

But It's NOT working on mobile In-App Browser (both iOS & Android), probably because on mobile messenger, it's not possible to allow the opening of multiple windows.

Are we missing something here? Any workaround for it?

Has anyone done that?

Replies

I actually found that if you hijack the window.open and replace it with window.location.href, you can use the same window to authorize rather than creating a new window:

window.open = function(url: string, windowName: string, windowFeatures: string) { 
    console.log('window caught', url, windowName, windowFeatures);
    window.location.href=url;
    return null;
  };

   

  • Hi, I'm quite interesting in how you complete the authorize procedure by hacking the window.open as a redirect way. Actually I attempt to do so but I cannot get the correct access token after the signin is successful and redirect back to my web app.

Add a Comment

Thank you for your question, @baltech

We have an article in our MusicKit on the Web v3 documentation that goes over how to handle this situation. See: MusicKit on the Web: Native Webviews