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

Enable "SafariViewController.hide()" for Chrome Custom Tabs #176

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

avewells
Copy link

Implemented fix as discussed in #105. Tested and is working fine in my use-case.

Works with and without <preference name="AndroidLaunchMode" value="singleTask" />. Although without the preference, SafariViewController.hide() causes a new "layer" of the Cordova app to be instantiated. This means that after manually calling SafariViewController.hide() the app's user would lose their place within the app because it's essentially restarting from what I can tell. Because of this, I would recommend that <preference name="AndroidLaunchMode" value="singleTask" /> is added.

Not sure that this would resolve #105, but it does enable SafariViewController.hide() to function on Android as it does iOS.

@kensodemann
Copy link

We did some testing on this and noted one minor change that was required to the modified code:

            case "hide": {
                cordova.getActivity().startActivity(new Intent(cordova.getActivity(), cordova.getActivity().getClass()));
                callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, true));
                return true;
            }

Just added the callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, true)); line to inform the webview. Otherwise if your app await's the hide() it will never resolve.

alexgonch added a commit to alexgonch/cordova-plugin-safariviewcontroller that referenced this pull request May 20, 2021
BendingBender added a commit to treefin/cordova-plugin-safariviewcontroller that referenced this pull request Jul 16, 2021
BendingBender added a commit to treefin/cordova-plugin-safariviewcontroller that referenced this pull request Jul 26, 2021
BendingBender added a commit to treefin/cordova-plugin-safariviewcontroller that referenced this pull request Jul 30, 2021
@Azer1652
Copy link

Azer1652 commented Dec 3, 2021

@EddyVerbruggen can this be merged?

@msalcala11
Copy link

+1 for a merge — just tested this PR, and it works great!

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.

hidden method for android
4 participants