cordova-plugin-inappbrowser
cordova-plugin-inappbrowser copied to clipboard
exit event is handled in ios diferently than in android
Bug Report
Problem
Event exit
is triggered in Android every time browser is closed - so if it is closed with browser.close()
or if it is closed via "Done" button in footer.
In iOS this event is triggered ONLY when a user clicks "Done" button, but it does not trigger when browser.close()
is called.
What is expected to happen?
Both platforms should handle it the same way - in my opinion, Android way of implementing it is the correct one.
What does actually happen?
Already described above.
Command or Code
import { Injectable } from '@angular/core';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
@Injectable()
export class Demo {
constructor(private iab: InAppBrowser) {}
public runBrowser(url) {
const browser = this.iab.create(url, '_blank', { usewkwebview: 'yes', hidden: 'yes' });
browser.on('loadstop').subscribe(async event => {
//this will not trigger exit event on ios, while on android it will
browser.close();
});
browser.on('exit').subscribe(event => {
console.log("exit");
});
}
}
Environment, Platform, Device
Android 9, iOS 13
Version information
"cordova": "^9.0.0",
"cordova-android": "^8.1.0",
"cordova-ios": "^5.1.1",
"cordova-plugin-inappbrowser": "^3.2.0",
Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
I've got almost the same (if not the same) issue. The 'exit' event is triggered correctly on iOS if the browser is not hidden.
So the code above will work as intended. The code below doesn't close the browser.
import { Injectable } from '@angular/core'
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx'
@Injectable()
export class Demo {
constructor(private iab: InAppBrowser) {}
public runBrowser(url) {
const browser = this.iab.create(url, '_blank', { hidden: 'yes' })
browser.on('loadstop').subscribe(async event => {
// browser is still running in background
browser.close();
})
browser.on('exit').subscribe(event => {
console.log("exit")
})
}
}
I'm using Ionic with latest versions:
Ionic:
Ionic CLI : 6.4.0 (~/.nvm/versions/node/v13.2.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.0.7
@angular-devkit/build-angular : 0.901.0
@angular-devkit/schematics : 9.1.0
@angular/cli : 9.1.0
@ionic/angular-toolkit : 2.2.0
Cordova:
Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : android 8.1.0, ios 5.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 21 other plugins)
Utility:
cordova-res : 0.11.0
native-run : 0.3.0
System:
ios-deploy : 1.9.4
ios-sim : 8.0.2
NodeJS : v13.2.0 (~/.nvm/versions/node/v13.2.0/bin/node)
npm : 6.14.4
OS : macOS Catalina
Xcode : Xcode 11.4 Build version 11E146
@KuschL you are correct, I missed that setting while making a small example. It's same for me, so I will edit main post.
Thanks.
Hey @alesrosina / @KuschL, did either of you find a fix for this?
Sadly no. I went with a bit different solution, but would be out of scope for this bug.
Any idea? :( other solution ?
Use const browser = this.iab.create('https://ionicframework.com/','_system','hidden=no'); and try!