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?

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;
  };

   

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

Hi, thank you for your article link (MusicKit on the Web: Native Webviews) @Media Engineer, I try your solution but on your STEP4, when i return to my website, MusicKit.getInstance().isAuthorized is always false, you know why ? Thank you.

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