Web Push Notification: How to use Web Push PHP Library?

后端 未结 2 904
一整个雨季
一整个雨季 2021-01-31 22:25

I Want to add Web Notification to my website. I searched on Google and found some tutorials about it. As described in these tutorials I manage to show subscription box to the vi

相关标签:
2条回答
  • 2021-01-31 22:44

    you have to add this code to your project https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/ sometimes you will have to add code to parts that you have already created

    0 讨论(0)
  • 2021-01-31 22:54

    Take a look at https://web-push-book.gauntface.com/ for a general introduction to Web Push. The Chapter How Push Works and Subscribing a User should be particularly interesting to you. In summary:

    • At the client side you need to create a subscription by calling pushManager.subscribe. More info here.
    • You should send this subscription to your server. For example, make an AJAX request to send the subscription (endpoint, keys.p256dh, keys.auth) to the server. More info here.
    • On the server you send a push message using the PHP Web Push library. First, you need to configure this library with your keypair. Then, you need to use the subscription (endpoint, keys.p256dh, keys.auth) to send a push message. More info here.
    0 讨论(0)
提交回复
热议问题