5

I developed a Progressive Web App and I want to publish it in the Play Store as a Trusted Web Activity. It's https://www.bagnoadriatico.it

Following this guide https://developers.google.com/web/updates/2019/02/using-twa

I downloaded the example from https://github.com/GoogleChromeLabs/svgomg-twa

I changed the configuration with

def twaManifest = [
    applicationId: 'com.simovinci.bagnoadriatico',
    hostName: 'www.bagnoadriatico.it', // The domain being opened in the TWA.
    launchUrl: '/mobile', // The start path for the TWA. Must be relative to the domain.
    name: 'BagnoAdriatico di Casalborsetti', // The name shown on the Android Launcher.
    themeColor: '#ff5c14', // The color used for the status bar.
    backgroundColor: '#ffff00' // The color used for the splash screen background.
]

then I signed the apk, build and published on play store.

In the website I created the association by Digital Asset Link https://www.bagnoadriatico.it/.well-known/assetlinks.json The "Statement List Generator and Tester" say that the operation was successful "Success! Host www.bagnoadriatico.it grants app deep linking to com.simovinci.bagnoadriatico." https://developers.google.com/digital-asset-links/tools/generator

The Address bar still visible, I don't know why.

https://www.bagnoadriatico.it/mobile returns a 200 http code. The PWA is 100% Lighthouse validated. The key finger print is right

========================================

I tried to set launchUrl = "/" (before I removed the 302 to mobile version) but nothing changed. The address bar is still visible.

Simo Vinci
  • 53
  • 5
  • Try to generate a release APK and try it on your phone. The address bar should not be there. – JeffProd Jun 09 '19 at 16:37
  • When I generated a release APK and installed it on my phone the address bar remains hidden. The problem is when I publish the application on the Store. – Simo Vinci Jun 10 '19 at 06:46
  • maybe a difficulty with /mobile. I had troubles with pwa when not installed at root. This is just a thought. Could you try https://mobile.bagnoadriatico.it instead ? – JeffProd Jun 10 '19 at 07:05
  • I tried with www.bagnoadriatico.it , but my PWA redirect mobile traffic to /mobile with a 302 http code. I think TWA need a 200 http code. I can try with mobile.bagnoadriatico.it I will let you know, thanks – Simo Vinci Jun 10 '19 at 08:25
  • I tried to set launchUrl to the root (before I removed the 302 to mobile version) but nothing changed. The address bar is still visible. – Simo Vinci Jun 10 '19 at 15:01

3 Answers3

5

If you have used app signing by Google Play, your SHA 256 changes. The fix is to download your app from the Play Store and then generate a new assetlinks.json file by using the following tool also from the Play Store:

https://play.google.com/store/apps/details?id=dev.conn.assetlinkstool&hl=en

Justin Pillay
  • 166
  • 2
  • 7
  • 1
    IT IS INCREDIBLE! IT WORKS! After a year without success I had completely lost hope. I had followed Google's guide instructions precisely but it still didn't work. This app is fantastic. Thanks – Simo Vinci May 11 '20 at 20:17
  • @SimoVinci You're welcome. Could you mark this question as solved? – Justin Pillay May 13 '20 at 10:15
  • it is nice some of you have successfully done this. i wish to ask if you encountered this issue. my assetlinks.json is tested correctly. when i try it in the emulator, the twa does not have a toolbar. but if i install it in my device, it says failed verification. thoughts? – chitgoks Oct 24 '20 at 11:08
  • @chitgoks have you tried using the app above on your device to generate a new assetlinks.json file? – Justin Pillay Oct 28 '20 at 19:36
  • i got it to work. there was an issue with the hosting such that only web browsers were allowed to view the file, had to change a different hosting provider. but it was weird that in my emulator with version 72 chrome it showed without a toolbar. – chitgoks Oct 29 '20 at 01:37
0

The assetlinks.jsonfile is actually wrong. It contains both the Android markup and the web markup:

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "web",
    "site": "https://www.bagnoadriatico.it"
  }
},{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target" : { "namespace": "android_app", "package_name": "com.simovinci.bagnoadriatico",
               "sha256_cert_fingerprints": ["DA:E2:7C:57:8F:B8:28:ED:C0:00:70:7C:52:1F:95:8E:50:E6:A9:58:50:B0:FB:9A:F1:99:78:C9:D4:6B:72:45"] }
}]

It would be enough for assetlinks.json to contain the following statement:

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target" : { "namespace": "android_app", "package_name": "com.simovinci.bagnoadriatico",
               "sha256_cert_fingerprints": ["DA:E2:7C:57:8F:B8:28:ED:C0:00:70:7C:52:1F:95:8E:50:E6:A9:58:50:B0:FB:9A:F1:99:78:C9:D4:6B:72:45"] }
}]

I'm not sure if this is the root cause for the address bar being visible. I'd also recommend double-checking:

  • Double check the fingerprints
  • Make sure there's no redirect to domain not validated when opening the URL.

Let me know if any of those helps.

andreban
  • 3,575
  • 1
  • 16
  • 40
  • I changed the file like you said, removing web markup. Unfortunately nothing has changed. I'm sure there are not redirects. I took the fingerprints directly from google play console. Is there anything else I can do? I would like to advertise my application before the summer :( – Simo Vinci Jun 20 '19 at 06:29
0

I found this issue only on emulator. It works perfectly on real device.

Issue was emulator does not load the signed APK.To load the signed apk on emulator add below code in gradle file

signingConfigs{
        debug{
            keyAlias 'your key alias'
            keyPassword 'your keypassword'
            storeFile file('keystore path')
            storePassword 'your storepassword'
        }
    }
    buildTypes {
        debug{
            signingConfig signingConfigs.debug
        }
 }  

Source

Gaya
  • 1