cordova-plugin-safariviewcontroller icon indicating copy to clipboard operation
cordova-plugin-safariviewcontroller copied to clipboard

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

Open bbialas opened this issue 3 years ago • 10 comments

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 avatar Jun 07 '21 15:06 bbialas

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>

bbialas avatar Jun 07 '21 19:06 bbialas

@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!

ucsbricks avatar Jun 18 '21 08:06 ucsbricks

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

daviesdoclc avatar Nov 05 '21 03:11 daviesdoclc

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!

AndrWeisR avatar Nov 10 '21 05:11 AndrWeisR

@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.

RenateM avatar Nov 30 '21 20:11 RenateM

@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.

sslife1 avatar Dec 01 '21 08:12 sslife1

@bbialas Fixed my issue aswell. Thanks

skrchr avatar Dec 07 '21 20:12 skrchr

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

related to https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller/pull/180

WuglyakBolgoink avatar Dec 08 '21 11:12 WuglyakBolgoink

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.

l3ender avatar Dec 21 '21 23:12 l3ender

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?

dcxn avatar Mar 29 '22 14:03 dcxn