PHP Classes

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 a PHP Push...  >  All threads  >  sending a notificatin example missing  >  (Un) Subscribe thread alerts  
Subject:sending a notificatin example missing
Summary:simple notification message
Messages:12
Author:Fm
Date:2020-05-05 12:13:44
 
  1 - 10   11 - 12  

  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

  6. Re: sending a notificatin example missing   Reply   Report abuse  
Picture of Finn Thorwarth Finn Thorwarth - 2021-01-19 14:23:18 - In reply to message 5 from Fm
I had the same Problem to understand how finaly to send the message because i`m not very confident in PHP. But for me opening the PNTestServer solved the problem :)

  7. Re: sending a notificatin example missing   Reply   Report abuse  
Picture of Stefan Kientzler Stefan Kientzler - 2021-01-19 22:14:19 - In reply to message 6 from Finn Thorwarth
Hi Finn,

great that you worked your way through :-)

the subject of this package to implement push notifications is quite a complex area i know it realy requires a certain amount of understanding - both for the subject itself and for PHP.

If my time give the posibility, I'll try to write a tutorial about the integration of the package, which is not about how the package works internally, but really just about how it can be integrated into an own project ...

- step by step -

... but this is essentially a question of my own time available - all i publish here is 'volunteer' ....

  8. Re: sending a notificatin example missing   Reply   Report abuse  
Picture of Mónika Székely Mónika Székely - 2021-02-26 10:44:32 - In reply to message 5 from Fm
Hello there,
Did you find out how it works?
I don't know no when and how trigger the saving subscribe php file.
Thanks,
Monika

  9. Re: sending a notificatin example missing   Reply   Report abuse  
Picture of Stefan Kientzler Stefan Kientzler - 2021-02-26 14:05:02 - In reply to message 8 from Mónika Székely
Hi Mónika,

I assume you mean the PNSubscriber.php with 'the saving subscribe php file'...
Saving the subscriptions is triggered by an HTTP request from the service worker (PNServoceWorker.js) on the user's computer - after all, the user wants to subscribe to the notifications ;-)

See the PNTestClient.html - Example.

regards, Stefan

  10. Re: sending a notificatin example missing   Reply   Report abuse  
Picture of Mónika Székely Mónika Székely - 2021-03-08 07:36:26 - In reply to message 9 from Stefan Kientzler
hi Stefan,

Thank you for your quick answer.

Could you tell me what part of the code rely on PHP7.
My company uses older version of php.

Many thanks,
Monika

 
  1 - 10   11 - 12