Problem with ngCordova's $cordovaInAppBrowser


#1

Hi,

I am using ngCordova's $cordovaInAppBrowser to open Apple Play Store URL. It opens the app store but it does not go into .then. Relevant code:

    $cordovaInAppBrowser.open(mktUrl, '_system', {location: 'yes', clearcache: 'yes', toolbar: 'no'}).
then(function(event) { ¬                            
      console.log("inside then"); ¬                           
      $state.go('odetails');
    }¬  

mktUrl is a app store URL for an app.

It does not generate any error. But it just doesn’t work. Please help.


#2

The inAppBrowser open function does not return a promise so you can’t use .then

You could create a event listener like they show in the documentation https://github.com/apache/cordova-plugin-inappbrowser

window.open = cordova.InAppBrowser.open;
var ref = window.open(url, target, options);
ref.addEventListener('loadstop', function() {
    //do something
});

This event listener would fire when the inAppBrowser has finished loading the page. You can also use ‘loadstart’ if you want the listener to fire when the loading starts.

Hope this helps.