Running angular service worker on mobile only

Hi,

We’re trying to run a service worker only on mobile platforms and not on desktops (cause desktops could be public which would be a issue).

However, the angular service worker is registered in the import segment of app.module.ts and i cant figure out if this could be restricted in some way.

With best regards,
Robin

I mean a mobile platform isn’t more secure than a desktop one

However you could probably add an environment variable to your build and modify your app.module.ts

 ServiceWorkerModule.register('ngsw-worker.js', {enabled: environment.production})

instead of environment.production use your own environment variable…I guess

Alright ill look into that. thanks.

On the secure part. A mobile device is not more secure. However physical access is less likely than on a public (lets say library) computer by a unknown party.

That’s an optimistic assumption, if someone want to have access to your app, he/she don’t care and gonna have access to it easily

I think it’s a best practice in terms of security to consider the all app, as long as it’s not a pwa in a private network for example, as full public

I figured facebook for example would cache a lot of images etc. to limit mobile bandwith usage. I would consider facebooks data as private for unauthorized party’s

Look I just wanted to point out the fact that I think that considering a desktop safer as a mobile app is a too optimistic mindset for not saying in my point of view, wrong, because for me both are fully public

But again I only told that in order to help, if you are not agree with me, no worries, no problemo, it’s your app, your data, your users, your call