0
我打算使用Web推送通知;我不知道我在哪裏可以找到auth
鍵:Javascript Web推送:我可以在哪裏獲得「身份驗證」密鑰?
var pushSubscription = {
endpoint: '< Push Subscription URL >',
keys: {
p256dh: '< User Public Encryption Key >',
auth: '< ???? User Auth Secret ???? >'
}
};
我可以從ServiceWorker>registeration.pushManager.getSubscription()
endpoint
和p256dh
但不auth
關鍵。
感謝
如果你想在JS中使用該對象(獲得鍵),請不要使用ab2string convertions或pushSubscription.keyKeys()...(Spoiler:不起作用。)只需執行以下操作: 'var subJSObject = JSON.parse(JSON.stringify(pushSubscription)); var endpoint = subJSObject.endpoint; var auth = subJSObject.keys.auth; var p256dh = subJSObject.keys.p256dh;' – mondjunge