GoogleChrome / GoogleChrome/android-browser-helper
Setting up TWA provider package name still opens default browser.
- Dominant language
- Java
- Stars
- 832
- Forks
- 370
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 6
Description
Hi guys,
As part of our app requirement, we are opening a webpage in a TWA fashion. We have been using chrome as our TWA provider passing non-whitelisted CORS headers.
Only recently, we started testing on other browsers that support TWA as mentioned here https://github.com/GoogleChrome/android-browser-helper/blob/main/docs/trusted-web-activity-browser-support.md and as per our testing
1. Firefox (org.mozilla.firefo) doesn't support TWA. onRelationshipValidationResult is never called.
2. Edge (com.microsoft.emmx) supports TWA, but doesn't support passing header all the time (the way shown in the demo project)
3. Samsung (com.sec.android.app.sbrowser) doesn't support TWA. onRelationshipValidationResult is never called.
Is this an issue with this library? How do we solve this?
Consequently, we decided to force the TWA provider to chrome (com.android.chrome).
The bug is, with edge installed and set to the default browser, even after setting the package name to that of chrome, the .launch() method still opens edge browser.
Attached below is the code
```
private val chromePackageName = "com.android.chrome"
val packageName =
CustomTabsClient.getPackageName(context, listOf(chromePackageName))
CustomTabsClient.bindCustomTabsService(
context,
packageName,
customTabsServiceConnection!!
)
val intentBuilder = TrustedWebActivityIntentBuilder(uri)
val intent = intentBuilder.build(customTabsSession!!)
// intent.intent.getPackage() always returns com.android.chrome, even if chrome is NOT set default
TwaLauncher(context).launch(intentBuilder, null, null, null) // this still opens edge
```
Steps to reproduce the behavior:
1. Have Edge browser installed and set to default app
2. On passing the chrome package name in the code snippet above still launched edge.
The expected behavior is that it should launch the chrome app in TWA and not Edge. What is the correct way to force open the TWA to the chrome browser?
- Device: Android Emulator arm64-v8a
- OS: Android 12
- Browsers Installed: Chrome, Edge
- Browser Versions: Edge(105.0.1343.50), Chrome(106.0.5249.126), Samsung and firefox (latest on the playstore)
- android-browser-helper library version: 2.4.0
Contributor guide
Assessment
This issue has not been assessed yet.