From 29e753a16d2945c62f77af3da1b71448ab63529e Mon Sep 17 00:00:00 2001 From: boynet <1615629+boynet@users.noreply.github.com> Date: Wed, 28 Nov 2018 19:05:02 +0200 Subject: [PATCH 1/2] customscheme and AllowedSchemes docs --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 503dd83b8..6ce8da23d 100644 --- a/README.md +++ b/README.md @@ -213,9 +213,17 @@ The object returned from a call to `cordova.InAppBrowser.open` when the target i - __loaderror__: event fires when the `InAppBrowser` encounters an error when loading a URL. - __exit__: event fires when the `InAppBrowser` window is closed. - __beforeload__: event fires when the `InAppBrowser` decides whether to load an URL or not (only with option `beforeload=yes`). - + - __customscheme__: event fires when the `InAppBrowser` load an custom schemes (Only when approved in AllowedSchemes preference). + - __callback__: the function that executes when the event fires. The function is passed an `InAppBrowserEvent` object as a parameter. +### Preferences + +- __AllowedSchemes__ (string, defaults to null). Configure the allowable schemes in a comma separated list in a new preference. This implements whitelisting for the allowed schemes, but doesn't use the Cordova Whitelist plugin. +to make your customscheme event to fire on this urls: `examplescheme://` and `othercheme://` add: + + + ## Example ```javascript @@ -238,6 +246,8 @@ function showHelp(url) { inAppBrowserRef.addEventListener('beforeload', beforeloadCallBack); + inAppBrowserRef.addEventListener('customscheme', customschemeCallBack); + } function loadStartCallBack() { @@ -300,11 +310,17 @@ function beforeloadCallback(params, callback) { } +function customschemeCallBack(event) { + + $('#status-message').text("An approved custome scheme url loaded, url:" + event.url); + +} + ``` ### InAppBrowserEvent Properties -- __type__: the eventname, either `loadstart`, `loadstop`, `loaderror`, or `exit`. _(String)_ +- __type__: the eventname, either `loadstart`, `loadstop`, `loaderror`, `customscheme`, or `exit`. _(String)_ - __url__: the URL that was loaded. _(String)_ @@ -344,6 +360,7 @@ function beforeloadCallback(params, callback) { - __loadstop__: event fires when the `InAppBrowser` finishes loading a URL. - __loaderror__: event fires when the `InAppBrowser` encounters an error loading a URL. - __exit__: event fires when the `InAppBrowser` window is closed. + - __customscheme__: event fires when the `InAppBrowser` load an custom schemes (Only when approved in AllowedSchemes preference). - __callback__: the function to execute when the event fires. The function is passed an `InAppBrowserEvent` object. From bac3dc15eccee250cc2f0d3a3c5659810b0e6742 Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Wed, 28 Nov 2018 20:32:35 +0200 Subject: [PATCH 2/2] typo Co-Authored-By: boynet <1615629+boynet@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ce8da23d..748b5310c 100644 --- a/README.md +++ b/README.md @@ -312,7 +312,7 @@ function beforeloadCallback(params, callback) { function customschemeCallBack(event) { - $('#status-message').text("An approved custome scheme url loaded, url:" + event.url); + $('#status-message').text("An approved custom scheme url loaded, url:" + event.url); }