I am creating building a Hybrid application using Ionic with ngCordova. In the application login workflow I am returning a page from server to the InAppBrowser plug-in. I need to read some values from the returned page in my Ionic app.
The usual way would be to call executeScript on 'loadstop' event, and setup a call back when that script returns something. And I have that setup as you can see in the following code. However, no matter what I try, iOS Emulator, Android Emulator the callback is not firing.
Here is the page that opens up the google website in InAppBrowser.
$cordovaInAppBrowser.open('http://google.com', '_blank', options)
.then(function (event) {
//alert('succed')
})
.catch(function (event) {
//alert('errored')
});
And following is the loadstop event handler. The 1+1 script is being injected fine because I do see the alert with 2. However the callback function is not being invoked at all !!
$rootScope.$on('$cordovaInAppBrowser:loadstop', function (e, event) {
$cordovaInAppBrowser.executeScript(
{
code: "alert(1+1);"
},
function (values) {
alert('add completed');
});
});
I gave multiple emulators a try but none of them are working. Appreciate your help in advance.