Comments (10)
The root element on assetlinks.json
is an array. You can use that to list multiple applications that have access to the domain:
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.mysamplehost.pwa1",
"sha256_cert_fingerprints": ["<82:04:C5:DB:19:A8:B9...>"]}
},{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.mysamplehost.pwa2",
"sha256_cert_fingerprints": ["82:04:C5:DB:19:A8:B9..."]}
},{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.mysamplehost.pwa3",
"sha256_cert_fingerprints": ["82:04:C5:DB:19:A8:B9..."]}
}]
A few things to note:
- Each entry has a different package name, which will point to the corresponded TWA
- You can use the same signing key or different signing keys. If using Play Store signing (recommended), those keys will probably be different.
- You will want to tweak the
intent-filter
in theAndroidManifest.xml
to handle things correctly. They would look something like this:
<intent-filter android:autoVerify="true">
<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="myexamplecost.com"
android:path="/pwa1" />
</intent-filter>
from svgomg-twa.
Hey,
Sorry, do you mind being a bit clearer about what you mean by "Is TWA capable of different PWAs on the same domain"? Do you just want a single TWA to be able to view each of your PWAs, or do you want to be able to create 3 different TWAs, one for each PWA?
While PWAs (things with the web app manifest) can have more specific scopes (eg, https://myexamplehost.com/pwa1), TWAs and Digital Asset Links really only care about origins (eg https://myexamplehost.com/).
If you want to have a single TWA that serves all your PWAs, you would:
- Create the assetlinks.json file at https://myexamplehost.com/.well-known/assetlinks.json.
- Add your single TWA to the assetlinks.json.
- Set up your TWA to launch to whichever PWA you want to first launch to.
- Create hyperlinks between your PWAs so users can move from one to another.
- Maybe make use of the
shortcuts
property inbuild.gradle
to create a shortcut to each PWA.
If you want to have 3 different TWAs, one for each PWA, you would:
- Create the assetlinks.json file at https://myexamplehost.com/.well-known/assetlinks.json.
- Create entries in assetlinks.json for each TWA.
- Set up each TWA to launch to its corresponding PWA.
Unfortunately in this second case things may get a bit confusing if you use Notification Delegation (essentially Chrome may get confused with which app should show your website's notifications) - but we can cross that bridge if we come to it.
Peter
from svgomg-twa.
Thank you for the explanation!
I like to have 3 different apps to be published to the google play store, one for each PWA. So I guess that I need 3 different TWA for that.
I couldn't find a good documentation about assetlinks.json How to create the correct entries in assetlinks.json and where to read on?
from svgomg-twa.
You can get some info about making your Digital Asset Links at the quick start guide here. Here is an example of a Digital Asset Link file that contains multiple verified TWAs.
from svgomg-twa.
@leolux I am working on something similar as you i.e. multiple twa on same domain . I want to know if the above solution worked for you and also how did you manage to enable push notifications in the three TWAs
from svgomg-twa.
Push notifications should work with multiple TWAs for the same origins, although the state is a little messy.
Basically, Chrome's permission model is keyed by the origin - so you've got the same notification permission for www.example.com, www.example.com/path and www.example.com/longer/path. For notification delegation auto-enrollment (where Chrome grants your website the notification permission provided your TWA has it), the permission for your entire origin will be the permission for whichever app has the broadest intent filter. However, the notifications themselves have a scope, so they may be routed to your specific TWAs, for example:
- TWA #1 has notification delegation enabled and an intent filter for www.example.com/.
- TWA #2 has notification delegation enabled and an intent filter for www.example.com/path.
The notification permission for www.example.com will be set according to that for TWA #1, however, if you send a notification from www.example.com/path, it will get routed to TWA #2 (which may not have notifications enabled).
(If on the other hand, you used different subdomains, (cats.example.com and dogs.example.com) everything should work and be a lot simpler.)
from svgomg-twa.
thanks for help @PEConn . Can you please also check this stackoverflow thread where I have asked my question more elaborately. Thanks
from svgomg-twa.
@andreban @PEConn
How to generate 'assetslinks.json' dynamically if i have thousands of PWA (pwa1, pwa2 .... so on). Can I add query param or path variable to the request(initiated from android for verification) decide the respective 'assetslinks.json' to be served from server?
from svgomg-twa.
The root element on
assetlinks.json
is an array. You can use that to list multiple applications that have access to the domain:[{ "relation": ["delegate_permission/common.handle_all_urls"], "target": { "namespace": "android_app", "package_name": "com.mysamplehost.pwa1", "sha256_cert_fingerprints": ["<82:04:C5:DB:19:A8:B9...>"]} },{ "relation": ["delegate_permission/common.handle_all_urls"], "target": { "namespace": "android_app", "package_name": "com.mysamplehost.pwa2", "sha256_cert_fingerprints": ["82:04:C5:DB:19:A8:B9..."]} },{ "relation": ["delegate_permission/common.handle_all_urls"], "target": { "namespace": "android_app", "package_name": "com.mysamplehost.pwa3", "sha256_cert_fingerprints": ["82:04:C5:DB:19:A8:B9..."]} }]A few things to note:
- Each entry has a different package name, which will point to the corresponded TWA
- You can use the same signing key or different signing keys. If using Play Store signing (recommended), those keys will probably be different.
- You will want to tweak the
intent-filter
in theAndroidManifest.xml
to handle things correctly. They would look something like this:<intent-filter android:autoVerify="true"> <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="myexamplecost.com" android:path="/pwa1" /> </intent-filter> `Great ! working fine
from svgomg-twa.
The root element on
assetlinks.json
is an array. You can use that to list multiple applications that have access to the domain:[{ "relation": ["delegate_permission/common.handle_all_urls"], "target": { "namespace": "android_app", "package_name": "com.mysamplehost.pwa1", "sha256_cert_fingerprints": ["<82:04:C5:DB:19:A8:B9...>"]} },{ "relation": ["delegate_permission/common.handle_all_urls"], "target": { "namespace": "android_app", "package_name": "com.mysamplehost.pwa2", "sha256_cert_fingerprints": ["82:04:C5:DB:19:A8:B9..."]} },{ "relation": ["delegate_permission/common.handle_all_urls"], "target": { "namespace": "android_app", "package_name": "com.mysamplehost.pwa3", "sha256_cert_fingerprints": ["82:04:C5:DB:19:A8:B9..."]} }]A few things to note:
- Each entry has a different package name, which will point to the corresponded TWA
- You can use the same signing key or different signing keys. If using Play Store signing (recommended), those keys will probably be different.
- You will want to tweak the
intent-filter
in theAndroidManifest.xml
to handle things correctly. They would look something like this:<intent-filter android:autoVerify="true"> <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="myexamplecost.com" android:path="/pwa1" /> </intent-filter> `Great ! working fine
This is not practical for 1000's PWA's. So I am generating assetliks.json dynamically as needed.
from svgomg-twa.
Related Issues (20)
- TWA top url bar not hiding HOT 2
- Unable to instantiate service androidx.browser.trusted.TrustedWebActivityService HOT 4
- how to use fcm push notification on TWA apk HOT 1
- Does TWA notification delegation handle sound also? HOT 9
- My TWA is crashing multiple times. HOT 7
- [Question] Adsense in PWA/TWA HOT 3
- Setting Notifications to true still asks for permission from user HOT 7
- Hide div in twa in-app browser HOT 1
- Running the TWA from a Chromebook just opens the URL in the browser and not a standalone window HOT 5
- TWA app can't run independently without running chrome browser first HOT 1
- Android TV app HOT 1
- open new a tab (url) inside of TWA by browser which is not inside of TWA HOT 1
- Update Android SDK studio to version 30 HOT 1
- Facebook Comments Plugin Not Working in The TWA HOT 1
- How to prevent app from going into background when a class 0 SMS (flash SMS) pops up thus preventing UPI verification.
- Android generating 404 errors on TWA website
- TWA asset ink is updated but address bar is visible HOT 4
- Android Browser Helper version HOT 2
- Multiple TWAs created for the same domain but google search only indexes one TWA HOT 1
- notifications only display when the phone is unlocked
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svgomg-twa.