Reputation: 77
I'm following the steps listed on the https://github.com/apache/cordova-plugin-inappbrowser#reference guide to install and configure Cordova's inAppBrowser. It states to wrap it in a 'deviceready' event listener and to fire after that - but nothing is firing, not even my console.log.
document.addEventListener("deviceready", onDeviceReady, false)
function onDeviceReady(){
console.log('Called on device ready!')
const browser = this.iab.create('https://google.com/', '_blank', 'location=no');
browser.show();
browser.on('loadstop').subscribe(event => {
console.log('Loaded!')
browser.close();
});
}
But nothing happens, and nothing is logged to the console.
What am I missing?
And yes, everything is installed and imported - went through those hurdles already.
Any advice or inputs are welcome, thanks!
Upvotes: 1
Views: 261
Reputation: 12139
I don't know wher you wrote:
document.addEventListener("deviceready", onDeviceReady, false)
so I can't tell why the event doesn't fire. However Ionic provides a ready()
method which is where you would put that initialization code.
This is copied straight from the default Ionic template in app.component.ts
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar
) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
}
You should have this code in your project if you created it with ionic start
.
Upvotes: 1