I am new to firebase cloud messaging; I have nuxt PWA (and a site). And I manage to have push notifications works when I know the client token. But sometimes, I want all my users who allow notifications to get notified when I send a message. I tried looking at similar issues like send to all devices and firebase send message to all and the docs, but I did not find a solution the no involves using the client token. This is my python code that sends the message. headers = { 'Content-Type': 'application/json', 'Authorization': 'key=' + serverToken, }
body = {
'notification': {'title': 'Sending push form python script!!!!!!!',
'body': 'New Message!!!',
'url': 'https://news7-vuf2ujuoha-ew.a.run.app/article/497927'
},
'to':
deviceToken,
'priority': 'high',
# 'data': dataPayLoad,
}
response = requests.post("https://fcm.googleapis.com/fcm/send",headers = headers, data=json.dumps(body))
print(response.status_code)
my nuxt PWA sw.js (by the way, I don't know the primary key for and what does the number says)
self.addEventListener('push', function (e) {
data = e.data.json();
var options = {
body: data.notification.body,
icon: data.notification.icon,
vibrate: [100, 50, 100],
click_action: data.notification.url || 'https://news7-vuf2ujuoha-ew.a.run.app/article/497921',
data: {
dateOfArrival: Date.now(),
primaryKey: ''
}
}
console.log(data, e);
})
print(response.json())
I am looking for a way, either with an API or from the GUI, to send push notifications to all my users (including the websites and PWA).