问题
I implemented web push notifications using service worker. I collected user subscriptions with a particular application server key. Suppose if we change the application server key, then when we get the subscription using "reg.pushManager.getSubscription()", we will get the old subscription information which was created using the old application server key. How to handle this scenario? How to get the new subscription from the user?
回答1:
Get the subscription using reg.pushManager.getSubscription()
and check whether current subscription uses the new application server key. If not, then call unsubscribe()
function on the existing subscription and resubscribe again.
来源:https://stackoverflow.com/questions/45994933/changing-application-server-key-in-push-manager-subscription