How to send a notification to multiple subscribers using web-push package of Node.js?

风格不统一 提交于 2019-12-12 18:11:54

问题


How we can send a notification to multiple subscribers using web-push package of Node.js?

We can loop through for list of subscribers but it won't be scalable for millions of subscribers.

Example:

for(var myKey in subData) {
    endp   =  subData[myKey]['ENDPOINT'];
    enckey =  subData[myKey]['ENCKEY'];
    webPush.sendNotification(endp, 200, enckey, JSON.stringify({
        title: 'Test Title',
        msg: 'Test Notification',
     }));
}

回答1:


Unfortunately, the Web Push standard currently doesn't support sending a notification to multiple subscribers.

Indeed, the key is related to a specific user. If all users shared the same key, the encrypted data would be readable by others. Read [1] for a more thorough explanation.

I'd suggest implementing a solution that sends notifications in batches, waiting a little between the batches. Usually the notifications don't have to be real-time, so this is usually feasible.



来源:https://stackoverflow.com/questions/34332632/how-to-send-a-notification-to-multiple-subscribers-using-web-push-package-of-nod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!