Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add closeAllIfPossible() method #67

Merged
merged 7 commits into from
Aug 26, 2023

Conversation

em-yhoshino
Copy link
Contributor

@em-yhoshino em-yhoshino commented May 26, 2022

What is this?

I have added closeAllIfPossible(), which closes all launched SFSafariViewControllers via flutter_custom_tabs, to launcher.

Before this PR

Once the app launched a SFSafariViewController via flutter_custom_tabs, it could not be closed until the user closed it. Therefore, the SFSafariViewController was masking the deep link transition.

After this PR

The app can close all SFSafariViewController at any time.
It is especially useful before deep link transitions.

How to use

Like this,

import 'package:flutter_custom_tabs/flutter_custom_tabs.dart' as custom_tabs;

await custom_tabs.launch(uriString);

// When deeplink is invoked
await custom_tabs.closeAllIfPossible();
await transition(deeplink);

It avoids occuring a transition behind a SFSafariViewController that is not closed by user.

Android and web

In Android and web, empty operations have been implemented because there is no proper way to close customTabs.
At least, Android doesn't require it in case of deep link scenario.
This is because customTabs are automatically closed when app returns from background.

@em-yhoshino em-yhoshino force-pushed the feature/close-for-droibit branch 3 times, most recently from b82aee4 to 842c0dc Compare May 26, 2022 08:32
@em-yhoshino
Copy link
Contributor Author

em-yhoshino commented May 26, 2022

The CI failed due to the dependency specification.
How can I solve it?

I think that we need to push the contents on this branch to pub.dev for the CI to be succeeded.

@Aulig
Copy link

Aulig commented Jul 12, 2022

Thank you so much for this, exactly what I needed. I'm also using deep links to hide the custom tabs on Android, works perfectly. For iOS there seems to be no other way than what you have done here to close the custom tabs (I tried all kinds of javascript & deep link shenanigans).

I had to download it locally and edit the pubspec files to get the dependencies to work like you said - not sure how to correctly fix it though so it'd work in the CI. Just wanted to thank you for this valuable feature.

@angeloborrelli
Copy link

Hello @em-yhoshino,
I really need your implementation of closeAllIfPossible() since in iOS, custom tab doesn't close after deep link and no way to close it manually so I'm trying to use your forked plugin version by putting this lines in my pubspec.yaml:

  flutter_custom_tabs:
    git:
      url: https://github.com/em-yhoshino/flutter_custom_tabs.git
      ref: master

Actually flutter pub get is returning this error:

Could not find a file named "pubspec.yaml" in https://github.com/em-yhoshino/flutter_custom_tabs.git eff797dda32aaa9bbc88af9e384f86e74f5a50d4.
pub get failed (1; Could not find a file named "pubspec.yaml" in https://github.com/em-yhoshino/flutter_custom_tabs.git eff797dda32aaa9bbc88af9e384f86e74f5a50d4.)
exit code 1

What am i doing wrong? Is it possible to test it or am i supposed to wait for @droibit to merge into a new officiale version?
Thanks for letting me know.
Regards
Angelo

@droibit
Copy link
Owner

droibit commented Aug 26, 2023

Thank you for the PR!
I apologize for not replying for a long time.

This plugin has not been maintained for a long time
so don't worry about the error on CI.

I will fix the workflows later.

@droibit droibit merged commit 8558a11 into droibit:develop Aug 26, 2023
1 of 3 checks passed
@Aulig
Copy link

Aulig commented Aug 27, 2023

Thank you for the PR! I apologize for not replying for a long time.

This plugin has not been maintained for a long time so don't worry about the error on CI.

I will fix the workflows later.

Thank you so much for coming back to this project! Looking forward to being able to use this version (not the fork) again once it's live on pub.dev :)

@droibit
Copy link
Owner

droibit commented Aug 30, 2023

The latest v1.11.0 with this PR has just been published on pub.dev!

Thank you for your patience.

@Aulig
Copy link

Aulig commented Aug 30, 2023

The latest v1.11.0 with this PR has just been published on pub.dev!

* https://pub.dev/packages/flutter_custom_tabs/versions/1.1.0

Thank you for your patience.

You're the best, thank you!

@droibit droibit self-assigned this Aug 31, 2023
@droibit droibit linked an issue Sep 9, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to close the in-app browser programmatically
4 participants