pwa-builder / PWABuilder

The simplest way to create progressive web apps across platforms and devices. Start here. This repo is home to several projects in the PWABuilder family of tools.
https://docs.pwabuilder.com
Other
2.84k stars 292 forks source link

Problems on serviceWorker and assetlinks #996

Closed Dav-Way closed 4 years ago

Dav-Way commented 4 years ago

Hello all,

We used PWABuilder to create a PWA app from a web app and it works great, thanks!

But we have 2 problems that we can't solve, can you please help us ?

1 / we created a directory /app/serviceWorker1/ containing the files pwabuilder-sw.js and pwabuilder-sw-register.js, but on the site https://www.pwabuilder.com the "service wordker" test still fails

2 / we created a directory /app/.well-known/ directory containing the assetlinks.json file, but the Browser Address Bar is still displayed on the wpa app

Thank you in advance.

Regards, David

ghost commented 4 years ago

Hello My2Eway, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will investigate the issue and help solve it ASAP. Other community members may also look into the issue and provide feedback 🙌

JudahGabriel commented 4 years ago

For the first issue about asset links and browser address bar, I believe Chrome requires that your assetlinks.json file be located at the root of the domain to prove ownership. Your assetlinks file should be at /.well-known/assetlinks.json. Can you try that?

For the second issue regarding service worker registration, I believe the service worker code looks for the service worker in a particular path. @jgw96 can you confirm?

jgw96 commented 4 years ago

Looking...

jgw96 commented 4 years ago

Hey @My2Eway , what does your pwabuilder-sw-register.js look like? Also, where did you get that file from if you dont mind me asking? Our service workers actually dont give you a sw-register file anymore so i'm just checking where you got that from. Also, our service worker tests do not look at a file path or anything anymore but actually just if your site has a service worker registered. The fact that one is not found for your site @My2Eway points to the service worker not being registered.

Dav-Way commented 4 years ago

Hello,

Thanks for the answers.

We put all files on the root of the web server like this :

https://project.buzzyapp.com/.well-known/assetlinks.json

https://project.buzzyapp.com/pwabuilder-sw-register.js

But the adress bar is still displayed, have you got some anotehers ideas please ?

Thanks in advance

Dav-Way commented 4 years ago

and the js files come from https://www.pwabuilder.com

JudahGabriel commented 4 years ago

@My2Eway it looks like you don't have a service worker: image

Looking at your HTML, it looks wrong to me:

image

As described here, your HTML should contain the following:

<script type="module">
   import 'https://cdn.jsdelivr.net/npm/@pwabuilder/pwaupdate';

   const el = document.createElement('pwa-update');
   document.body.appendChild(el);
</script>

That script will find a pwabuilder-sw.js file and register it as your service worker.

Dav-Way commented 4 years ago

Hello,

We updated the javascript code, and it look like the service worker is running.

But there is no change on app, the adress bar is till present.

Can you please check if there is some other problem on our app ?

Thanks in advance.

JudahGabriel commented 4 years ago

Did you follow the steps from our Remove the address bar article?

Dav-Way commented 4 years ago

yes , i check this page and follow the stepds

do yo see any problems on my site / app please ?

JudahGabriel commented 4 years ago

What's the name of your app in the Google Play store? I'd like to install it and test out some things.

Dav-Way commented 4 years ago

The actual name is "buzzyapp"

here is the link : https://play.google.com/store/apps/details?id=com.buzzyapp.project.twa&hl=fr

JudahGabriel commented 4 years ago

The issue is your asset links are incorrect. As documented in Remove the Address Bar, you need to verify your asset links are correct.

(You likely have incorrect asset links if you opted into Google Play resigning your APK, resulting in different asset links.)

To fix this, update your assetlinks.json file to the following:

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.buzzyapp.project.twa",
    "sha256_cert_fingerprints": [
      "AB:51:1D:87:56:D2:06:67:BA:4F:FD:A7:4D:C0:98:3D:A4:8E:96:94:A3:35:D1:E2:9C:5B:6E:E2:9C:CB:6E:25",
      "C1:5A:37:F5:E3:8F:A6:BA:F1:13:30:BF:7E:7C:9B:F3:19:B8:67:72:ED:CD:25:BA:94:57:97:84:80:02:18:09"
    ]
  }
}]

Please update your asset links file, then let us know if it works. 👍

Dav-Way commented 4 years ago

Hello,

Thanks for you answser.

I've upload the new assetlinks.json : https://project.buzzyapp.com/.well-known/assetlinks.json

But there is no change, as you can see in this screenshot :

Screenshot_20200903-094530_Samsung Internet

JudahGabriel commented 4 years ago

It's working for me:

image

Your local device may have had the assetlinks.json file cached. Refresh it in Chrome, then reinstall the app. (Alternately, serve assetlink.json with a no-cache header.)

Let me know if it works for you.

Dav-Way commented 4 years ago

yes it works with chrome, thanks a lot ! it was a cache problem as you described

with the samsung internet browser the address bar is present, but maybe this browser dont fully support PWA ?

JudahGabriel commented 4 years ago

Glad your issue is fixed!

With regards to Samsung Browser, I'll need to check with the Google team to see whether Android Trusted Web Activities (TWA) are fully supported in their browser. @davrous do you know?

In the meantime, @My2Eway, if you need Samsung support without the browser address bar, please open a new issue for that. 👍

Dav-Way commented 4 years ago

@JudahGabriel do you mean i need to create a new issue on github for pwa samsung support ? (and close this one #996) ?

JudahGabriel commented 4 years ago

@David-My2eWay Yes, since this issue is about asset links and service worker, I recommend you open a new issue for your Samsung browser issue.

Dav-Way commented 4 years ago

ok, its done 👍

https://github.com/pwa-builder/PWABuilder/issues/1109