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

Android 11 (SDK 30) - Chrome Custom Tabs not available #179

Open
bbialas opened this issue Jun 7, 2021 · 10 comments
Open

Android 11 (SDK 30) - Chrome Custom Tabs not available #179

bbialas opened this issue Jun 7, 2021 · 10 comments

Comments

@bbialas
Copy link

bbialas commented Jun 7, 2021

Plugin version used: 2.0.0

After changing Cordova Target SDK version to 30 (Android 11) and app is running on the device with Android 11, this plugin doesn't work anymore.

Code that I use

window.SafariViewController.isAvailable((available: any) => {
    if (available) {
        window.SafariViewController.show(
            {
                url: params.url,
                hidden: false,
                animated: true,
                transition: "slide",
                enterReaderModeIfAvailable: false,
                tintColor: "#00ffff",
                barColor: "#000000",
                controlTintColor: "#ffffff",
                showDefaultShareMenuItem: false
            },
            (result: any) => {},
            (err: any) => {}
        );
    }
});

available always returns false.

Any ideas?

@bbialas
Copy link
Author

bbialas commented Jun 7, 2021

I realized, that this plugin is not able to get available browsers from the device anymore (which supports Custom Tabs).

After reading google documentation:
https://developers.google.com/web/updates/2020/07/custom-tabs-android-11#detecting_browsers_that_support_custom_tabs

Following change to config.xml fixed the problem.

<config-file target="AndroidManifest.xml" parent="/manifest">
    <queries>
        <intent>
            <action android:name="android.support.customtabs.action.CustomTabsService" />
        </intent>
    </queries>
</config-file>

Example:

<?xml version='1.0' encoding='utf-8'?>
<widget
    id="xxx"
    version="xxx"
    xmlns="http://www.w3.org/ns/widgets"
    xmlns:cdv="http://cordova.apache.org/ns/1.0"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android-versionCode="xxx"
    ios-CFBundleVersion="xxx"
>
    <name>xxx</name>
    <description>xxx</description>
    <content src="index.html" />
    <access origin="*" />
    ........
    <platform name="android">
        <preference name="android-targetSdkVersion" value="30"/>
        .........
        <config-file target="AndroidManifest.xml" parent="/manifest">
            <queries>
                <intent>
                    <action android:name=
                        "android.support.customtabs.action.CustomTabsService" />
                </intent>
            </queries>
        </config-file>
    </platform>
</widget>

@ucsbricks
Copy link

@bbialas I created a pull request implementing your fix. Thanks for figuring this out! @EddyVerbruggen could you please test and merge this fix? Thanks guys!

@daviesdoclc
Copy link

Any idea when this will be released or do I just have to apply the patch myself?

@AndrWeisR
Copy link
Contributor

I realized, that this plugin is not able to get available browsers from the device anymore (which supports Custom Tabs).

After reading google documentation: https://developers.google.com/web/updates/2020/07/custom-tabs-android-11#detecting_browsers_that_support_custom_tabs

Following change to config.xml fixed the problem.

<config-file target="AndroidManifest.xml" parent="/manifest">
    <queries>
        <intent>
            <action android:name="android.support.customtabs.action.CustomTabsService" />
        </intent>
    </queries>
</config-file>

Example:

<?xml version='1.0' encoding='utf-8'?>
<widget
    id="xxx"
    version="xxx"
    xmlns="http://www.w3.org/ns/widgets"
    xmlns:cdv="http://cordova.apache.org/ns/1.0"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android-versionCode="xxx"
    ios-CFBundleVersion="xxx"
>
    <name>xxx</name>
    <description>xxx</description>
    <content src="index.html" />
    <access origin="*" />
    ........
    <platform name="android">
        <preference name="android-targetSdkVersion" value="30"/>
        .........
        <config-file target="AndroidManifest.xml" parent="/manifest">
            <queries>
                <intent>
                    <action android:name=
                        "android.support.customtabs.action.CustomTabsService" />
                </intent>
            </queries>
        </config-file>
    </platform>
</widget>

Confirmed!

@RenateM
Copy link

RenateM commented Nov 30, 2021

@EddyVerbruggen and @ucsbricks, thanks for this great plugin! This issue is, unfortunately, causing the login process of my app to malfunction. I would also really appreciate this fix to be released soon as the Google Play Store is not going to accept an update to my app without my app targeting Android SDK version 30.

@sslife1
Copy link

sslife1 commented Dec 1, 2021

@EddyVerbruggen and @ucsbricks, thanks for this great plugin! This issue is, unfortunately, causing the login process of my app to malfunction. I would also really appreciate this fix to be released soon as the Google Play Store is not going to accept an update to my app without my app targeting Android SDK version 30.

I'm having the same issues with login.
Although the added queries made the safariviewcontroller work.

@skrchr
Copy link

skrchr commented Dec 7, 2021

@bbialas Fixed my issue aswell. Thanks

@WuglyakBolgoink
Copy link

check my plugin (https://github.com/WuglyakBolgoink/cordova-plugin-quick-fix-svc) as a fallback

related to #180

@l3ender
Copy link

l3ender commented Dec 21, 2021

Thanks all for the work identifying the issue and developing the solution! It would be great to get the fix merged in and released, so workaround approaches can be avoided.

S-AT added a commit to S-AT/cordova-plugin-safariviewcontroller that referenced this issue Jan 7, 2022
@dcxn
Copy link

dcxn commented Mar 29, 2022

Hey, same issue and seeing an ERROR {error: "custom tabs are not available"} in my console. And again, thank you all for identifying and proposing solution.

Any ETA for merging the fix and releasing new update?

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

No branches or pull requests

10 participants