理解推送权限
用户必须给予您的网站权限才能向他们发送推送通知。如果不使用系统级权限提示明确授予站点权限,就不可能接收推送通知。
- Default: permission has not been granted to denied.
- Granted: you allowed the website to send you notifications.
- Denied: you blocked the website to send you notifications. This can be a temporary block if you clicked the x to close the prompt repeatedly or a permanent block if you clicked Block or toggled off permission in the browser settings.
有关原生系统级权限提示和/或任何 OneSignal 提示的更多详情,请参阅 Web 权限提示。
如何取消订阅 Web 通知
您可以通过三种方式取消订阅 Web 推送通知:在浏览器设置中取消订阅
您可以在浏览器设置中直接管理或删除通知权限。这里是快速访问 URL 和官方文档以了解更多信息:- Chrome:
chrome://settings/content/notifications(Learn more on Chrome’s docs) - Edge:
edge://settings/content/notifications(Learn more on Microsoft’s docs) - Firefox:
about:preferences#privacyscroll to Permissions > Notifications > Settings (Learn more on Mozilla’s docs) - Safari: Settings > Websites > Notifications (Learn more on Safari’s docs)
在网站上取消订阅
Reset permission 大多数浏览器在 URL 旁边都有一个“锁”或“设置”图标。点击它会显示特定站点权限,用户可以在此处禁用推送通知。

删除浏览器数据、清除 Cookie 和站点数据
如果您删除历史记录和/或删除您的 Cookie 和网站数据,它将临时阻止通知显示。但是,如果您不从网站中删除推送权限,您可能会在返回网站时自动重新订阅并再次开始收到通知。

如何测试您的权限提示
这些步骤解释如何像首次访问者一样测试您的提示和订阅流程。访问已设置 OneSignal SDK 的站点。
Do not use an incognito, private, or guest browser setting. This example uses Chrome version 135 on macOS but the flow should be relatively the same for most browsers.
重置推送权限
Click the site settings or lock icon next to the site URL and select Reset permission or remove permissions for Notifications.
Skip to the next step if you don’t see this permission option.

删除站点数据。
Click Cookies and site data > Manage on-device site data or follow the browser’s flow to see your site’s data option.
删除您网站的数据并退出设置以返回您的网站。


按照步骤提示推送通知,在所需的系统级权限提示中选择"允许"。
If you do not see the prompt or don’t know the steps, see Web permission prompts.

检查控制台是否有任何错误。
If you see anything in red related to OneSignal, see our Web SDK troubleshooting docs.
获取订阅 ID
在控制台中输入或复制粘贴此代码:

OneSignal.User.PushSubscription.id- 这将记录您的 OneSignal 订阅 ID。将其复制粘贴到 OneSignal 仪表板的受众 > 订阅选项卡中。
- 如果控制台中未记录订阅 ID,则您未成功订阅。请查看 Web SDK 故障排除 了解详情。


导航至消息 > 推送 > 新消息 > 新推送,在推送创建表单中添加消息。
See Push for more details if needed.

您应该收到测试的推送。
If you did not receive a push, see Web push: Notifications not shown for further debugging.

You have successfully setup web push with OneSignal. Next steps:
- Web push setup - additional non-developer web setup steps.
- Web SDK setup - developer web SDK setup steps.
- Web SDK troubleshooting - troubleshooting if you see errors in the console or not getting a subscription ID.
- Web push: Notifications not shown - troubleshooting notifications not displaying on your device.
在浏览器关闭时接收通知
浏览器在不同平台上的行为不同。请参阅下表了解在浏览器关闭时仍可接收通知的支持情况。| Browser Name | Android | Windows | macOS |
|---|---|---|---|
| Chrome / Chromium | Yes | Yes | No |
| Firefox | Yes | Yes | No |
| Safari | N/A | N/A | Yes |
| Opera | Yes | Yes | No |
| Edge | Yes | Yes | No |

