I have successfully completed an Ionic Android Application. Now, i am migrating the same to IOS. But, the inAppbrowser events are not being called/listened at all.
I used ngCordova to access the inappbrowser which works fine in Android. In iOS, the inappbrowser opens but after that no event listener gets fired. Tried this with both emulator and device. The only warning i see on emulator is
testv2[808:134364] THREAD WARNING: ['InAppBrowser'] took '45.421875' ms. Plugin should use a background thread.
Here are my app versions:
$cordova -v
v6.5.0
$ionic -v
v2.2.1
iOS version - 10.12.2 (16C67)
Kindly, help out.
**Note: I am completely new to IOS.
First i added,
<access-origin="*"/>
<allow-navigation href="*" />
Then, in my html,
<ion-view view-title="Playlists">
<ion-content>
<button ng-click="openBrowser()">Click me</button>
</ion-content>
</ion-view>
In Playlists Controller,
.controller('PlaylistsCtrl', function($scope,$cordovaInAppBrowser,$rootScope) {
$scope.openBrowser = function() {
// body...
var options = {
location: 'yes',
clearcache: 'yes',
toolbar: 'yes'
};
document.addEventListener("deviceready", function () {
$cordovaInAppBrowser.open('http://ngcordova.com', '_system', options)
.then(function(event) {
// success
})
.catch(function(event) {
// error
});
$cordovaInAppBrowser.close();
}, false);
$rootScope.$on('$cordovaInAppBrowser:loadstart', function(e, event){
alert(loadstart);
console.log("loadstart");
});
$rootScope.$on('$cordovaInAppBrowser:loadstop', function(e, event){
alert(loadstop);
console.log(loadstop);
// insert Javascript via code / file
});
$rootScope.$on('$cordovaInAppBrowser:loaderror', function(e, event){
alert("loaderror");
console.log("logerror");
});
$rootScope.$on('$cordovaInAppBrowser:exit', function(e, event){
});
solved it through plain window.open method
var ref = window.open(url, '_blank','clearcache=yes,location=no,toolbar=yes');
ref.addEventListener('loadstart', handleEvents, false);
ref.addEventListener('loadstop', handleEvents, false);
var handleEvents = function(event) {}