GithubHelp home page GithubHelp logo

Comments (10)

andreban avatar andreban commented on July 17, 2024 3

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:

  1. Each entry has a different package name, which will point to the corresponded TWA
  2. You can use the same signing key or different signing keys. If using Play Store signing (recommended), those keys will probably be different.
  3. You will want to tweak the intent-filter in the AndroidManifest.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.

PEConn avatar PEConn commented on July 17, 2024

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:

  1. Create the assetlinks.json file at https://myexamplehost.com/.well-known/assetlinks.json.
  2. Add your single TWA to the assetlinks.json.
  3. Set up your TWA to launch to whichever PWA you want to first launch to.
  4. Create hyperlinks between your PWAs so users can move from one to another.
  5. Maybe make use of the shortcuts property in build.gradle to create a shortcut to each PWA.

If you want to have 3 different TWAs, one for each PWA, you would:

  1. Create the assetlinks.json file at https://myexamplehost.com/.well-known/assetlinks.json.
  2. Create entries in assetlinks.json for each TWA.
  3. 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.

leolux avatar leolux commented on July 17, 2024

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.

PEConn avatar PEConn commented on July 17, 2024

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.

the-white-tiger avatar the-white-tiger commented on July 17, 2024

@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.

PEConn avatar PEConn commented on July 17, 2024

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:

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.

the-white-tiger avatar the-white-tiger commented on July 17, 2024

thanks for help @PEConn . Can you please also check this stackoverflow thread where I have asked my question more elaborately. Thanks

from svgomg-twa.

jitendra1607 avatar jitendra1607 commented on July 17, 2024

@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.

Mohit-Hasan avatar Mohit-Hasan commented on July 17, 2024

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:

  1. Each entry has a different package name, which will point to the corresponded TWA
  2. You can use the same signing key or different signing keys. If using Play Store signing (recommended), those keys will probably be different.
  3. You will want to tweak the intent-filter in the AndroidManifest.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.

jitendra1607 avatar jitendra1607 commented on July 17, 2024

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:

  1. Each entry has a different package name, which will point to the corresponded TWA
  2. You can use the same signing key or different signing keys. If using Play Store signing (recommended), those keys will probably be different.
  3. You will want to tweak the intent-filter in the AndroidManifest.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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.