Ionic hybrid app - close window from server


I am building an ionic hybrid app. the native app is a simple one page (setting page) with ‘go to app’ button (it will have login credentials in the future).

The ‘go to app’ button opens by,’_self’).'', '_self', 'location=yes');

The app on the server is also build with ionic.

I want to close the ‘window’ from the server and get back the the ‘settings page’ on the native app.

I’ve tried so many things for the past 4 hours, and ended with no success.

Any suggestion on how it can be done?

Has anyone encountered this issue?

Thanks in advance.


you should have a redirect in you backendpage to a page you can identify as “please close my app” something like a unique url like:

in your app

var externalPaymentWindow = $'URL', '_blank', 'location=yes,enableViewportScale=yes');
// everytime a new site is loaded
externalPaymentWindow.addEventListener('loadstart', function (event) {
  // current windowurl
  var url = event.url;
  // check if current url contains close
  if (url.indexOf('/close') !== -1) {
    // close window