PushSubscription: endpoint property
注意:此功能在 Web Workers 中可用。
PushSubscription 接口的 **endpoint** 只读属性返回一个字符串,其中包含与推送订阅关联的端点。
此端点是一个指向推送服务器的自定义 URL,可用于向订阅了推送服务的特定 service worker 实例发送推送消息。因此,最好对端点保密,以防止他人劫持和滥用推送功能。
值
字符串。
示例
js
navigator.serviceWorker.ready.then((reg) => {
reg.pushManager.subscribe({ userVisibleOnly: true }).then((subscription) => {
console.log(subscription.endpoint);
// At this point you would most likely send the subscription
// endpoint to your server, save it, then use it to send a
// push message at a later date
});
});
规范
| 规范 |
|---|
| 推送 API # dom-pushsubscription-endpoint |
浏览器兼容性
加载中…