Google chrome 如果一台设备上的Google chrome已经接收到web推送通知,那么有没有办法停止该设备上的Google chrome上的web推送通知?
我已经使用谷歌chrome上的web推送功能实现了推送通知Google chrome 如果一台设备上的Google chrome已经接收到web推送通知,那么有没有办法停止该设备上的Google chrome上的web推送通知?,google-chrome,push-notification,service-worker,progressive-web-apps,Google Chrome,Push Notification,Service Worker,Progressive Web Apps,我已经使用谷歌chrome上的web推送功能实现了推送通知 如果在另一台设备上的Google chrome上已经接收到web推送通知,是否有方法停止在一台设备上的Google chrome上的web推送通知?这将要求您在向最终用户推送通知之前访问分布式存储中的某些内容。例如,您的逻辑可能类似于: // Only one client can get a lock at a time var lock = await api.getPushNotificationDistributedLock()
如果在另一台设备上的Google chrome上已经接收到web推送通知,是否有方法停止在一台设备上的Google chrome上的web推送通知?这将要求您在向最终用户推送通知之前访问分布式存储中的某些内容。例如,您的逻辑可能类似于:
// 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
,并成功发送推送通知。将状态更新为已完成
后,每个后续客户端将看到状态为已完成并继续