I have application which use app links for login in the browser outside of the app and is redirected back after login is completed. This works fine with android native browsers but fails when I'm using Chrome Custom Tabs. User is logged in custom tabs and not redirected back to the app, so I wonder if is it possible to use app links with custom tabs in the same way as with the native browsers?
manifest configuration
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="my-host"
android:scheme="https" />
working implementation in native browsers
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
ContextCompat.startActivity(context, intent, null)
failing redirect using chrome custom tabs
val customTabsIntent = CustomTabsIntent.Builder()
.build()
customTabsIntent.launchUrl(context, Uri.parse(url))
Because your deeplink url is like that of a website, the Chrome Custom Tab will always try to load it as a webpage instead of redirecting. What you could do is use a scheme not commonly supported by a browser like app-name://
then your host could be redirect-to
so what this would play out to be would be
<data
android:host="redirect-to"
android:scheme="app-name" />
This way only your app, will be the one to resolve this url. But take note when you use this type of url, it may not appear as a link in some apps like e-mails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With