sending a notificatin example missing

Recommend this page to a friend!

      PHP Web Push Notifications Server  >  PHP Web Push Notifications Server package blog  >  How to Use PHP to Sen...  >  All threads  >  sending a notificatin example missing  >  (Un) Subscribe thread alerts  
Subject:sending a notificatin example missing
Summary:simple notification message
Messages:5
Author:Fm
Date:2020-05-05 12:13:44
 

 


  1. sending a notificatin example missing   Reply   Report abuse  
Picture of Fm Fm - 2020-05-05 12:13:44
so much good work, amazing.
Yet no example of usage. There is nothing said about what to do after registration. Surely the should be easy to demo what to do next, i.e. to then send a simple notification message

  2. Re: sending a notificatin example missing   Reply   Report abuse  
Picture of Stefan Kientzler Stefan Kientzler - 2020-05-05 13:47:19 - In reply to message 1 from Fm
Sections 2.2 and 2.3 describe exactly how the subscriptions can be saved on the server and how messages are sent. And the entire code is included in the package - you just have to create your own VAPID key to get started ...

  3. Re: sending a notificatin example missing   Reply   Report abuse  
Picture of Fm Fm - 2020-08-03 13:20:39 - In reply to message 2 from Stefan Kientzler
Hi,
I have returned to try & create a simple example to use this package. A good package but I still think it would be great if you supply a simple example e.g.
A php file to send "hello"
A php file to receive "hello".
The installation instruction are fine, I have registered & I then get :
PUSH Notifications not subscribed so far
Secure context: true
Notification: defined
PushManager: defined
serviceWorker: defined
Notification.permission: granted
Running the example I get:
Push - Log:
https://fcm.googleapis.com
The request to send a push message was received and accepted.
resonse code: 201 ()
Sadly There is nothing to show how to benefit from this package by the very last simple( to you I'm Sure) example of how to use to send xxxxx then how to receive yyyyyy.
Thank you

  4. Re: sending a notificatin example missing   Reply   Report abuse  
Picture of Stefan Kientzler Stefan Kientzler - 2020-08-03 18:07:12 - In reply to message 3 from Fm
Hi Fm,

as you describe it, you obviously followed all the steps correctly to get your first push notification:

1. Generate your own VAPID keys as described in readme.md and
- enter the public key in PNServiceWorker.js
- enter both keys and email in PNTestServer.php in the following place

// set the VAPID key
$oVapid = new PNVapid (
"mailto: yourmail@yourdomain.de",
"the-generated-public-key",
"the-generated-private-key"
);

2. Open the PNTestClient.html page
-> Click the [Subscribe PUSH Notifications] button
-> To check, reload the page again ([F5])
-> "PUSH Notifications are subscribed" should now be displayed

3. Open the PNTestServer.php page
-> the first notification should appear on your PC next to the information displayed on the page

From here it is difficult for me to narrow down a source of error without further information if the notification is not displayed.

  5. Re: sending a notificatin example missing   Reply   Report abuse  
Picture of Fm Fm - 2020-08-04 10:54:32 - In reply to message 4 from Stefan Kientzler
Thank you again. I have no errors and your package works but what I meant there I see no clarity on how to use IN an application. I think you need a simple example NOT for installation or registration...etc. but for day to day use.
For example:
Usage in your app:
1) your app needs to run this js code at start: pnSubscribe();
2) every time you need to send a notification, your app needs to ?????????. May be run the whole file PNTestServer.php ???? with a new message?
I don't know.
Above points may be wrong, it's my explanation to what i feel would really make this package popular.
Steps for using this package once the installation bits work.
Many thanks

 

For more information send a message to info at phpclasses dot org.