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

后端 未结 2 943
一整个雨季
一整个雨季 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: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.

提交回复
热议问题