Reputation: 41
I have a very basic Android app generated from https://appmaker.xyz/pwa-to-apk/. That app was actually modeled very closely off an example published by Google which I cannot find anymore.
The problem is that if you set the default browser on the device to one that does not support TWA, the app opens but shows the URL bar. If you want all the technical fun, here's a bug report that explains everything: https://bugs.chromium.org/p/chromium/issues/detail?id=942930
My Android development skills are limited to compiling the app in Android Studio and I have no clue what modification I can make to force my app to prefer a browser that supports TWA. Is there some modification I can make to that will do this?
Here's my AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.placeholder">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="${launcherName}"
android:supportsRtl="true"
android:theme="@style/Theme.TwaSplash">
<meta-data
android:name="asset_statements"
android:value="${assetStatements}" />
<activity android:name="android.support.customtabs.trusted.LauncherActivity"
android:label="${launcherName}">
<meta-data android:name="android.support.customtabs.trusted.DEFAULT_URL"
android:value="${defaultUrl}" />
<meta-data
android:name="android.support.customtabs.trusted.STATUS_BAR_COLOR"
android:resource="@color/colorPrimary" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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="https"
android:host="${hostName}"/>
</intent-filter>
</activity>
</application>
</manifest>
Upvotes: 4
Views: 1804
Reputation: 4976
Browser support for Trusted Web Activity is improving - Chrome, Edge, and a couple of others support it, with Firefox coming soon (Firefox Nightly already supports it).
The example was svgomg-twa, which is now deprecated.
The best way to generate a an app that uses Trusted Web Activity is using something like Bubblewrap - It's a Node.js CLI application.
It defaults to the Custom Tabs fallback behaviour (the URL bar) but has the option to enable a WebView fallback.
bubblewrap init --manifest=https://example.com/manifest.json
twa-manifest.json
. Edit this file and change the fallbackType
field from customtabs
to webview
.bubblewrap update
bubblewrap build
Alternative approach:
PWABuilder uses Bubblewrap as a library and can be used for the same goal:
Build my PWA
Options
Done
Download
Upvotes: 2