Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push notification not getting delivered via service workers

We have deployed the chrome service worker on our website in July 2015 and have over 380K active subscribers of which over 90% are mobile devices. But we are encountering issues with the service worker. When a user's cache gets cleared or when many of the mobile apps like cleanmaster and other utility apps on a phone clear cache on a user's mobile. In that case we do not have any access to device token of that user. And hence even with 380K active users for which google sends us message ids we only get 50K impressions which is a very low ratio. Our push notification subscription is implemented on a seperate subdomain as we could not make the entire site https then.

I have 2 queries:

  1. We would love to know if Google is working on setting up a canonical system (Which is there in GCM for mobile apps) through which even if the user's cache gets cleared via these apps he might be able to get push notifications. Our users have complained again and again that even after subscription they are not receiving push that's when we went deeper and figured this out.
  2. Also is there a way through which we can ensure we get back those users ?
like image 356
Gaurav Dahake Avatar asked Apr 15 '16 14:04

Gaurav Dahake


People also ask

Why do some people not receive push notifications?

Silent mode: Android devices have a “do not disturb” mode and a “no distractions” mode. If you have enabled either of these, you won't receive any notifications.

Why am I not getting notifications even though they are turned on?

Cause of Notifications Not Showing up on AndroidDo Not Disturb or Airplane Mode is on. Either system or app notifications are disabled. Power or data settings are preventing apps from retrieving notification alerts. Outdated apps or OS software can cause apps to freeze or crash and not deliver notifications.

Are push notifications guaranteed to be delivered?

Push notifications use a push notification gateway or service, which do not guarantee timely delivery. Also, while push notifications might get to a device in a timely fashion, certain settings on a user's device e.g. power-saving mode can still delay notification appearance.

Why user can't see notifications even though it was successfully sent to user's device?

This could happen because of slow internet issues on the user's device. Under such circumstances, the text would get loaded but the image might still fail due to poor network.


1 Answers

When a user clears their cache in Chrome, it also unregisters service workers and clears the window cache as well. By unregistering the service workers it will unsubscribe the push subscriptions.

I agree that it's hard to understand the link between clearing a cache / cookies and how that relates to service worker and push notifications from the UI - the Chrome team are aware of this.

The best advice with respect to getting those users back is to ensure that when ever a user enables notifications and you get a subscription object, keep track of that decision as their last known decision and when the user re-visits your site, if they should be subscribed and you have permission, you can get a new subscription and send that back to your server.

Update

I put together this blog post: https://gauntface.com/blog/2016/05/01/push-debugging-analytics

Looking at your site there are a few issues in your code:

  • it seems that you have several broken promise chains and and overall it's hard to reason with what is going on in the push event, I'd strongly recommend tidying it up.
  • There is a minor but obvious bug when the service worker start ups and tries to examine the push subscription, which doesn't exist.
  • You are registering two service workers but only one of them gets used for push.

Checkout the blog post above, it covers how I came to that conclusion and some advice on how to fix it.

like image 192
Matt Gaunt Avatar answered Oct 21 '22 00:10

Matt Gaunt