gpt4 book ai didi

push-notification - 服务 worker 中的 Angular Push 通知错误,JSON 中的意外 token P 位于位置 0

转载 作者:行者123 更新时间:2023-12-04 14:38:09 25 4
gpt4 key购买 nike

我正在尝试在 pwa 中使用推送通知,但未能收到通知。

在客户端,我收到以下错误

Uncaught SyntaxError: Unexpected token P in JSON at position 0
at Driver.onPush (ngsw-worker.js:1967)
at ngsw-worker.js:1871

I add an image that includes the data that reaches the service worker

正如您在上一张图片中看到的,数据字段为空,但是当我发送它时,我添加了一个文本

为了测试应用程序,我发布了以下通知:

https://web-push-codelab.glitch.me/

我已经感谢任何贡献。

最佳答案

如果您的有效负载采用任何 json 格式,如上面的格式,则不会出现错误,但不会在您的客户端中显示通知,也不会显示其他错误消息。您必须使用某种 json 格式。一种最小的工作负载是:

{ "notification": {"title": "message title", "body": "message body"} }

我还没有找到这个 json 的准确和完整的规范,但是 here (搜索“payload”)你会找到一个更完整的例子。

关于push-notification - 服务 worker 中的 Angular Push 通知错误,JSON 中的意外 token P 位于位置 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53934873/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com