AppAuth-Android icon indicating copy to clipboard operation
AppAuth-Android copied to clipboard

No matter what I do all browsers return false for useCustomTab

Open KevinPosim opened this issue 8 years ago • 13 comments

Set up Chrome as default browser com.android.chrome with version 69.0.3497.100 has browser.useCustomTab = false

Set up Firefox as default browser org.mozilla.firefox with version 62.0.3 has browser.useCustomTab = false

Looking at this data in the AuthorizationService constructor by setting a break point and inspecting the browser variable.

Tried to white list Chrome, Firefox and Samsung browser via AppAuthConfiguration but then it just gives activity not found exception in the console and program stops.

Run simple test of CustomTabsIntent.Builder().build().launchUrl(this, Uri.parse("https://www.cnn.com"))

This runs and uses a custom tab in the app without any issue so custom tabs are usable via code on the device using either browser.

App is built using androidx libraries 1.0.0, Kotlin version 1.2.71, supportLibVersion = '28.0.0'

KevinPosim avatar Oct 19 '18 18:10 KevinPosim

It's caused by Jetifier. I wrote about it over here: https://github.com/openid/AppAuth-Android/issues/417#issuecomment-433111586

FizzyMobile avatar Oct 25 '18 16:10 FizzyMobile

I moved all the library code into a module in my app. I then converted it all to use ANDROIDX format and swapped line 187 of BrowserSelector to

    serviceIntent.setAction(CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION);

And now all is working fine in my app. Conversion to ANDROIDX touches nearly every file in the project.

KevinPosim avatar Oct 29 '18 18:10 KevinPosim

I moved all the library code into a module in my app. I then converted it all to use ANDROIDX format and swapped line 187 of BrowserSelector to

    serviceIntent.setAction(CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION);

And now all is working fine in my app. Conversion to ANDROIDX touches nearly every file in the project.

Hi Kevin

Will you be able to post a link to with your solution with AndroidX? E.g. an aar file with the library..

I'm currently stuck with "Cannot change strategy of configuration ':app:compile' after it has been resolved" when trying to convert to AndroidX :(

porkyhead avatar Nov 20 '18 16:11 porkyhead

porkyhead Would love to help you out. I currently just have this included as a module in my project so I don't build an aar file or create any sort of library out of it. If there is a good way for me to zip it up and put someplace for you I am totally willing to do that. Don't know the best way to connect. Maybe you can post your Reddit name, LinkedIn name, etc. and we can start contact that way.

KevinPosim avatar Nov 20 '18 16:11 KevinPosim

Sounds great Kevin. You can find me on Reddit as "porkyhead".

porkyhead avatar Nov 20 '18 17:11 porkyhead

@KevinPosim @porkyhead I downloaded the library code, upgraded it to use AndrodiX and made the change mentioned above. I imported the aar file in my test project. I made the following change.

    private static boolean hasWarmupService(PackageManager pm, String packageName) {
        Intent serviceIntent = new Intent();
        serviceIntent.setAction(CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION);
        serviceIntent.setPackage(packageName);
        return (pm.resolveService(serviceIntent, 0) != null);
    }

Still, it has not helped me. I get the same issue again. usCustomTab returns false. Any more pointers as to what I can do to fix this custom tab issue? Thank you so much in advance.

karunanaik avatar Dec 07 '18 18:12 karunanaik

It would be fantastic to add AndroidX support for custom tabs adapting the library like @KevinPosim did.

XabierGoros avatar Dec 12 '18 12:12 XabierGoros

Is a release scheduled at all to include Android X support to fix the custom tabs issue?

tmdues avatar Dec 13 '18 15:12 tmdues

Until we get a fixed version of Jetifyer, are you able to use: maven { url "https://dl.bintray.com/hnljp/AppAuth-Android" } '0.7.0-43-g8ce60dc' it is using this code: https://github.com/hnljp/AppAuth-Android/tree/JetifierCompatible

hnljp avatar Dec 13 '18 15:12 hnljp

I was also facing the same issues, please refer this fix https://github.com/openid/AppAuth-Android/pull/438

silentsudo avatar Jan 09 '19 06:01 silentsudo

@hnljp hello, are you still using this library? Could you please update your branch with the last version 0.7.1?

andreluizreis avatar Jun 26 '19 02:06 andreluizreis

is JetifierCompatible in 0.7.1 yet?

ptc-wguo avatar Feb 14 '20 00:02 ptc-wguo

Library is using androidX since 0.8.0 so this should no longer be an issue.

agologan avatar Apr 08 '21 17:04 agologan