Reputation: 2516
I'm trying to implement AddeventListener to listen 'Exit' and 'LoadStart' for InAppBrowser in IONIC2
my html
<button (click)="browsersystem('https://www.google.com')" > URL</button>
mt.TS file
browsersystem(url:string)
{
this.platform.ready().then(() => {
let browser=open(url, "_system", "location=true");
browser.addEventListener('exit',()=>
{
console.log('Browser Closed');
alert('Browser Closed');
})
browser.addEventListener('loadstart',()=>
{
console.log('Browser STARTED');
})
});
}
No errors on console.
Is there something am i missing ??
Upvotes: 1
Views: 2386
Reputation:
This should do the trick, see below :
this.platform.ready().then(success => {
let browser = new InAppBrowser(url, '_system');
browser.on('exit').subscribe(
() => {
console.log('done');
},
err => console.error(err));
});
Upvotes: 1
Reputation: 7370
import {InAppBrowser} from 'ionic-native';
...
let browser=InAppBrowser.open(url, "_system", "location=true");
browser.addEventListener('exit',()=>
{
console.log('Browser Closed');
alert('Browser Closed');
});
This is not at all how it's documented / how it should work, but as the code currently stands, this is what works for me.
Upvotes: 1