Search code examples
javascriptionic-frameworkinappbrowser

Ionic Inappbrowser: Custom Events


I would like to receive a custom Event from the Webpage running inside the Ionic In-App-Browser.

For example:

 this.browser.on('buttonOnWebSitePressed').subscribe(event => {
  that.browser.hide();
});

Is that possible? If so: How do I need to throw the event from the Webpage

Or does .on(...) only work with events like loadstart, loadstop, loaderror or exit?


Solution

  • Check the docs of the InAppBrowserPlugin (Cordova).

    As far as I can see, there are only four possible events (in this plugin) to catch from your ionic application:

    • loadstart: event fires when the InAppBrowser starts to load a URL.
    • loadstop: event fires when the InAppBrowser finishes loading a URL.
    • loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
    • exit: event fires when the InAppBrowser window is closed.

    Edit: There are some workarounds. One is to call a URL via a button in injected into the inappbrowser and then check the "loadstart" event for that URL.