Giter Club home page Giter Club logo

Comments (8)

SangKa avatar SangKa commented on September 21, 2024

image

需要订阅时的用户详情,而示例中的 /sendMessage 接口需要手动传入这些参数,代码如下:

https://github.com/deanhume/progressive-web-apps-book/blob/05c5f67bd11829491f7e012ec689085fe55434e9/chapter-6/push-notifications/server.js#L35-L47

from pwa-book-cn.

amplee avatar amplee commented on September 21, 2024

谢大神回复,但这段代码我有加的,还是不能触发/sendMessage,而且我看了下,/register的参数跟他的是一样的吧?假如我把这index.html的/register请求改成/sendMessage,在页面首次打开的并点击允许接受通知就能显示/sendMessage的推送内容了,但是后面不能再触发任何推送了,是我描述的不清楚吗?

from pwa-book-cn.

amplee avatar amplee commented on September 21, 2024

订阅时的用户详情,是一定要保存到数据库才能用吗?首次推送的时候不是获取了用户的订阅详情吗?我调了断点,首次发起的请求(不管是/sendMessage还是/register)能进去,后面怎么点击页面都进不去这两个推送了。

from pwa-book-cn.

amplee avatar amplee commented on September 21, 2024

我迷惑的点是,如何第二次触发这个推送,就比如怎么才能再次触发/sendMessage这个推送服务?

from pwa-book-cn.

SangKa avatar SangKa commented on September 21, 2024

需要改造下代码,前端改也行,后端改也行,目的就是要把注册成功后的那几个重要参数保存好,然后让后端发推送通知时可以正常使用这些参数。/register 好用就是因为它已经把这些参数准备好了。
不知道这样说你能明白嘛

from pwa-book-cn.

amplee avatar amplee commented on September 21, 2024

我先把参数保存下来试一下,谢谢!
所以这个是因为参数信息的缺失造成的?像/register的推送是因为在index.html里发出了这个请求才发起的推送,那是在什么情况下触发了/sendMessage这个推送呢?浏览器自己触发的?过多长时间会触发呢?

from pwa-book-cn.

SangKa avatar SangKa commented on September 21, 2024

我看了下,代码里并没有触发 /sendMessage 接口的操作,建议后端保存参数,前端正常发 /sendMessage 请求即可

from pwa-book-cn.

amplee avatar amplee commented on September 21, 2024

好的,我先试一下,谢谢耐心解答~!

from pwa-book-cn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.