@bash88 Getting can’t use property open of undefined
I was using the latest one available at the time of writing.
Hi Sujan, Just passing by to day, that indead there is problem with the code:
the problem happens when we use the browser.
the on function returns a Promise instead of an Observable.
it seems to be comming from decorator.js
export function InstanceCheck(opts) {
console.log("opts",opts);
if (opts === void 0) { opts = {}; }
return function (pluginObj, methodName, descriptor) {
return {
value: function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (instanceAvailability(this)) {
return descriptor.value.apply(this, args);
}
else {
if (opts.sync) {
return;
}
else if (opts.observable) {
return new Observable(function () { });
}
return getPromise(function () { });
}
},
enumerable: true
};
};
}
please have a look, thanks
Perhaps the issue is caused by the device platform not ready when attempting to subscribe to the event?
I did the following and it works fine on iOS simulator (10.3) and Android emulator (6.0):
...
import { Platform } from 'ionic-angular';
import { InAppBrowser } from '@ionic-native/in-app-browser';
...
export class HomePage {
private iab: InAppBrowser;
private platform: Platform;
private browser;
...
$scope.openURL = function(url) {
this.platform.ready().then(
() => {
this.browser = this.iab.create( url, "_blank", "EnableViewPortScale=yes,closebuttoncaption=Done" );
this.browser.on("exit").subscribe(
(event) => {
this.close_event = true;
},
(err) => {
console.log("InAppBrowser Loadstop Event Error: " + err);
}
);
}
);
};
...
}
Basically I simply put any calls to InAppBrowser
methods inside Platform.ready()
.
in my experience the events are subscribed if the target is not _self
ie: using target _blank the events are correctly subscribed, otherwise, if I user target _self, no events are subscribed
cli packages:
@ionic/cli-plugin-proxy : 1.4.13
@ionic/cli-utils : 1.13.1
ionic (Ionic CLI) : 3.13.1
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.0.0
Cordova Platforms : android 6.3.0 browser 5.0.0 ios 4.5.2
Ionic Framework : ionic-angular 3.7.1
System:
Android SDK Tools : 26.1.1
Node : v8.0.0
npm : 2.15.12
OS : Linux 4.13
Misc:
backend : pro
Work perfect with me. ionic-angular 3.9.2
let browser = this.util.iap.create(tip.url, '_blank', 'location=no,allowInlineMediaPlayback=yes,hardwareback=yes,presentationstyle=pagesheet,shouldPauseOnSuspend=yes,closebuttoncaption=DONE?');
browser.on('exit').subscribe((ev)=>{
console.log('load exit...');
});
browser.on('loadstop').subscribe((ev)=>{
console.log('load stop...');
})
browser.show();