Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome 如果一台设备上的Google chrome已经接收到web推送通知,那么有没有办法停止该设备上的Google chrome上的web推送通知?_Google Chrome_Push Notification_Service Worker_Progressive Web Apps - Fatal编程技术网

Google chrome 如果一台设备上的Google chrome已经接收到web推送通知,那么有没有办法停止该设备上的Google 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()

我已经使用谷歌chrome上的web推送功能实现了推送通知


如果在另一台设备上的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
,并成功发送推送通知。将状态更新为
已完成
后,每个后续客户端将看到状态为已完成并继续