When I use Android WebView
there are ways to communicate between web-app and native with JS interface
call as well as JS Injection
call. I wonder if there in any work around to communicate between Android native app and Chrome Custom Tab (CCT)
by any mean?
I know for security reason Google does not added bridging feature in CCT
and TWA
. But in Google I/O, they declared that there are limited ways of Web/Native bridging
(refer the below figure). I wonder what are the ways as well as where can I find guidelines regarding these limited bridging?
<activity android:name=".activities.MyResultActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="abc"
android:host="abc.oauth.com" />
</intent-filter>
</activity>
When I am calling abc://abc.oauth.com
in browser it does not open my activity. Its opening google search.
Finally I got the query params key/value with below code successfully,
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Log.d(classTag, "MyResultActivity activity is called")
intent?.data?.let {
for (key in it.queryParameterNames) {
val value = it.getQueryParameter(key)
Log.d(classTag, "MyResultActivity param key: $key, value: $value")
}
}
}
Thanks a lot @Rahul for guiding me onwards.
There is a nice tutorial here which show how to create it step by step.
The main idea behind the whole thing is Intent-Filters with category browseable which will get called whenever the redirect URL is called.
<intent-filter android:label="@string/filter_view_http_gizmos">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="callback_param"
android:scheme="anything"/>