Ionic 2 - inAppBrowser issue

533 views Asked by At

I am very new to this Ionic 2 Framework and have never worked with Cordova.

I am sending users to the payment gateway page to complete the transaction and once completed I am not able to close the window using JavaScript, due to this error:

Scripts may close only the windows that were opened by it

Have tried all possible way but none of them can be put in use.

Even closing the inAppBrowser once the user is navigated to a specific URL will work, but I am unable to find any supporting document to this and I do feel this is possible.

1

There are 1 answers

0
GreatBlacksmith On BEST ANSWER

If you are using inAppBrowser plugin ( https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/) you can add event listener and check if specific url was opened.

Example:

inAppBrowser.addEventListener("loadstop", function (event) {
    if (event.url.indexOf('UrlIAmChecking') != -1) { 
            inAppBrowser.close();
    }
 }