Re: [w3c/push-api] Retry push event (#300)

Some more thinking...

> I also believe that you can call ServiceWorkerRegistration.showNotification() inside a Background Sync. Am I wrong?

Yes, you can use that. I have found that some blog posts ([example](http://frontend.turing.io/lessons/module-4/background-sync.html)) actually use it inside `sync`. Also it would make sense because `showNotification()` is just a function provided by service workers and it must always work, inside any event.

> There certainly are use-cases for push messages that don't carry a payload

Thinking about additional cases where **you may want to use a fetch before displaying the notifications** are the following:

- stronger authentication with the application server (using normal sessions for example); the notifications can be displayed only if the user is actually logged in
- prefetch content before displaying the notification to the user; e.g. first I download the new items (e.g. email, news, etc.) in the local cache and then when content is ready to be displayed I show the notification; in this way we reduce user wait time and we can also wait to display the notification until the content is actually accessible

Also talking about bandwidth usage of an additional fetch when `push` is received, I think it has a very negligible effect compared to the technology as a whole. Note that a notification may cause multiple connections: persistent connection to push service, icon, image, 2x action button icons, and maybe others (e.g. prefetch application content).

> The only problem I can see in this approach is that userVisibleOnly will not detect that the push event has displayed the notifications. This problem is specific to the Push API: can we find a solution for this?

So **Background Sync seems the perfect solution... the only worry is about `userVisibleOnly`**. The actual problem is that you don't define an algorithm for `userVisibleOnly`. The only general definition is this:

> The userVisibleOnly option, when set to true, indicates that the push subscription will only be used for push messages whose effect is made visible to the user, for example by displaying a Web Notification. 

I think that you should define that more clearly (step by step) and **allow notifications to be displayed _indirectly_ by the `push` even (e.g. inside a `sync`)**. 
A simple algorithm that would solve this is to keep the number of `push` received in a day and the number of `notifications` displayed in a day. Then `userVisibleOnly` can be considered satisfied if: number of notifications > 0.90 * number of `push` received.




-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/push-api/issues/300#issuecomment-419640844

Received on Saturday, 8 September 2018 13:07:16 UTC