Search code examples
angularjscordovaionic-frameworkinappbrowser

How can I close the InAppBrowser automatically when specific content is returned?


How can I automatically close the $cordovaInAppBrowser when it goes to my website and returns content "OK"? I would like to do this to avoid displaying the close button in the browser window.

Does anyone know how I can achieve this?


Solution

  • I did find the website that can solve this for those who also need to self close the browser in some condition.Here is the reference link : https://developer.salesforce.com/forums/?id=906F00000009ALSIA2

    sample coding:

    authWindow.addEventListener('loadstop', function(e) {
    var loc = e.url;
    //when url is changed check if the url contains your specific callbackURL
    if (loc.search(data.callbackURL) >= 0) {
    //at this point close your inapp browser
    //you will land on the index page within your application.
    authWindow.close();
    //your code after successful authentication
    }
    });