capacitor-plugins
capacitor-plugins copied to clipboard
feat: provide a workaround for Browser.close() on android
Feature Request
Provide a workaround for Browser.close() on android, in order to provide the same features on all platforms.
Description
As i understand it, capacitors goal is to provide the same api and features on all platforms (wherever possible). This currently seems to be not the case with the Browser plugin, as Browser.close() does not work on android (also documented). For me, this makes the plugin pretty much unusable, as i build my app for ios and android...
Currently i have to use cordova-plugin-inappbrowser, which is not a preferable solution. It would be very nice, if we could solely rely on capacitor to do this :)
Platform(s)
android
Preferred Solution
Provide a workaround for Browser.close() on android
Alternatives
Use cordova-plugin-inappbrowser (not really a preferable solution)
BTW: I know that the android implementation uses chrome custom tabs and this does not provide a close functionality. However, there seems to be a workaround by using broadcasts and redirect to the activity, that opened the chrome custom tab. Maybe this solution could be used: https://gist.github.com/im182cm/2c7723d42b2d7091af6c493b97b732b7
Any news?
Any news on this ?
Any news on this issue?
Any news on this issue?
We could do with this too - any update?
Not being able to close the browser is a huge issue. Please, could you make it number one priority for this project? Thank you.
My workaround was to use Observables.
I turned the Browser.open() into an observable with from and pipe takeUntil with a void Subject to cancel the observable. Worked on Android but not iOS for me
My workaround was to use Observables.
I turned the Browser.open() into an observable with from and pipe takeUntil with a void Subject to cancel the observable. Worked on Android but not iOS for me
That sounds promising. Do you have an example?
The workaround I'm using (on Android at least) is cordova-plugin-browser instead of cordova-plugin-inappbrowser and then simply use the new browser "Close" ('X') feature.
My workaround was to use Observables. I turned the Browser.open() into an observable with from and pipe takeUntil with a void Subject to cancel the observable. Worked on Android but not iOS for me
That sounds promising. Do you have an example?
@cyrilfr Sure, this is a simplified example but it's something along those lines:
const cancel$ = new Subject<void>();
from(Browser.open({url}))
.pipe(takeUntil(cancel$))
.subscribe()
//Whenever you need, call next to cancel the previous observable
cancel$.next();
I work with Ionic/Angular, i don't know how it would look like with React and Vue.
What version of Capacitor are you using? I tried with this code but that didn't work:
const cancel$ = new Subject<void>();
from(Browser.open({ url }))
.pipe(takeUntil(cancel$))
.subscribe();
setTimeout(() => cancel$.next(), 5000);
It looks like there's a PR that has addressed this issue and it simply needs to have some formatting updated so that it'll pass linting. If there's anybody that has submitted PRs to Ionic before and knows the protocol for taking over the PR and getting it across the finish line.
Added PR #1107 with the import fixes for #151 and added call.resolve() for async await support.
Added PR #1107 with the import fixes for #151 and added call.resolve() for async await support.
You are a rockstar and a scholar! Fingers crossed the PR is merged "soon" 🤞
Any updates on this? It's been 8 months since the PRs were opened... Thanks!
I would also love to have this PR merged!
It would be great if this PR could be completed! Who should we reach out to for approval?
It is absolutely necessary to close the browser in case of auth redirections or they will not work within the web view. In case of Google auth, Cordova InAppBrowser is not secured from Google perspective and it will show an error. Consider some apps may have only Google as authentication option. Capacitor Browser plugin needs to address these issues.
Its' been 3 years now, this is an absolutely necessary feature of this plugin.
We need an answer if this will be completed or not! Thank you
Any update on the PR ??
Meeeeeeeeerge please
I'm using patch-package in the interim to automate the patch as part of the build.
Really? Ionic team. 4 years in the making, and you do not have an answer or direction to this? In the mean time new version of Ionic is coming out, but a BASIC thing like closing an in app browser is NOT supported on Android. Someone seems just not interested in making this work. This is disappointing.. you would think it would be better than this.
Really? Ionic team. 4 years in the making, and you do not have an answer or direction to this?
In the mean time new version of Ionic is coming out, but a BASIC thing like closing an in app browser is NOT supported on Android. Someone seems just not interested in making this work.
This is disappointing.. you would think it would be better than this.
It's another PR was merged. Just try latest version, it should work fine in Android as well.
I can confirm it's working on Android, so this ticket can be closed.
Only the documentation needs to be updated (it still says "no-op on other platforms")