Chrome for Android don't receive FCM message

961 views Asked by At

I made some push notifications for my site, using FCM service. There is code for it (from redux saga):

const reg = yield navigator.serviceWorker.register('/sw.js', {scope: '/'})
const sub = yield reg.pushManager.subscribe({
    userVisibleOnly: true,
    applicationServerKey: push_key,
})
const token = JSON.stringify(sub.toJSON())
console.log(token)

Service worker:

self.addEventListener('push', function(event) {
console.log(event)
if (!self.Notification || self.Notification.permission !== 'granted')
    return

let data = {}
if (event.data)
    data = event.data.json()
const title = data.title || 'Something Has Happened'
const message = data.message || 'Here\'s something you might want to check out.'

event.waitUntil(self.registration.showNotification(title, {
    body: message,
    tag: 'simple-push-demo-notification',
}))
})

I manually init push message by simple python script:

import json
from pywebpush import webpush

t = json.loads('{"endpoint":"https://fcm.googleapis.com/fcm/send/xxx","keys":{"p256dh":"xxx","auth":"xxx"}}')
webpush(t,
    json.dumps({'title': 'hello', 'message': 'world!'}),
    vapid_private_key="xxx",
    vapid_claims={"sub": "mailto:[email protected]"})

It works totally ok for desktop Chrome and Firefox, showing notifications, but mobile Chrome don't receive any message at all. I tried some push examples and is same story - they just don't show notifications on mobile. I used Chrome 60 on Android 4.2 and Android 7.1.

So, does mobile Chrome supports push notifications? I'm totally confused. That answer says "No" and give some doc link, but i cannot find in that docs something about mobile support or unsupport. That answer says what notifications works only in stock browsers and not in Chrome. But official documentation says (and even show gif!) what all should be ok on mobile!

0

There are 0 answers