cordova-plugin-inappbrowser icon indicating copy to clipboard operation
cordova-plugin-inappbrowser copied to clipboard

documenting the custom schemes handling

Open boynet opened this issue 6 years ago • 4 comments

I am not native english so I cant create a pr for this, but we need to documente the lastest changes in custom schemes handling (https://github.com/apache/cordova-plugin-inappbrowser/pull/263 and https://github.com/apache/cordova-plugin-inappbrowser/pull/274)

the things to document: for example to allow whatsapp custom scheme and twitter

  • add new config.xml preference with the custom schemes you want to support:
<preference name="AllowedSchemes" value="whatsapp,twitter" />`
  • add event listeners customscheme:
inAppBrowserRef.addEventListener('customscheme', function (event) {
            //do whatever you want here like:
             window.open(event.url, "_system");
        });

boynet avatar Nov 27 '18 15:11 boynet

Thanks @boynet, seems like a reasonable thing to do. Where would you put those in the README/documentation? Feel free to open a new PR even with imperfect English, we can iterate on the wording with suggestions and comments!

janpio avatar Nov 27 '18 15:11 janpio

@boynet , @janpio I was trying since two days and I could not find a solution. I'm using ionic, cordova, angular5 with typescript. And here my example


this.iab.create(myUrl, "_system");
this.iab.on('loadstart') // will never be triggered

Could you write me a sample that I can follow using _system as target (system browser).

Thanks.

engharb avatar Dec 28 '18 12:12 engharb

Thanks for mentioning this here. It would be nice if this was added to the documentation, because, to my knowledge, it appears to be the only way on Android to handle redirects back to the app using a custom url scheme. I've used this for the Adyen and Okta oAuth redirect.

intodevelopment avatar Jun 16 '20 19:06 intodevelopment

As @boynet commented https://github.com/apache/cordova-plugin-inappbrowser/pull/263#issuecomment-442143355 , this works the 1st time a customscheme is opened. The following times, the callback is never called. This is linked to https://issues.apache.org/jira/browse/CB-13198 and the fix is simple: add the customscheme event to the _system InAppBrowser after opening it.

Heshyo avatar Oct 23 '21 15:10 Heshyo