我已经使用在Google chrome上工作的web-push实现了推送通知。
如果一台设备上的Google chrome已经在另一台设备上接收到了网络推送通知,有没有办法阻止它?
发布于 2019-11-20 11:17:24
这将要求您在将通知推送到最终用户之前访问分布式存储中的某些内容。例如,您的逻辑可能类似于:
// Only one client can get a lock at a time
var lock = await api.getPushNotificationDistributedLock();
// Get the status
var pushNotificationStatus = await api.getPushNotificationStatus();
// Send the notification if it hasn't already been sent
if(pushNotificationStatus === "pending") {
// Push notification to user
await api.setPushNotificationStatus("completed");
}
// Release the lock
lock.release();第一个获得锁的客户端将看到状态为pending,并成功发送推送通知。在它将状态更新为completed后,每个后续客户端都将看到状态为已完成并继续。
https://stackoverflow.com/questions/58933267
复制相似问题