PHP Classes

How to send notification after installation

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  >  How to send notification after...  >  (Un) Subscribe thread alerts  
Subject:How to send notification after...
Summary:How to send notification after installation
Messages:4
Author:john doe
Date:2023-06-02 14:09:43
 

  1. How to send notification after...   Reply   Report abuse  
Picture of john doe john doe - 2023-06-02 14:09:43
Hello

I managed to download and set up this package correctly.

I can register for notifications and it appears in the database successfully.

After this point, how would I send another notification? For example. How could I just send a "Hello world" notification to the user?

  2. Re: How to send notification after...   Reply   Report abuse  
Picture of Stefan Kientzler Stefan Kientzler - 2023-06-02 14:25:33 - In reply to message 1 from john doe
Hi John - ... doe? ;-)

jut take a look at the example files
PNTestPushSingle.php
and
PNTestServer.php
in the packages root directory to see, how to send a push notification.

  3. Re: How to send notification after...   Reply   Report abuse  
Picture of john doe john doe - 2023-06-02 14:39:42 - In reply to message 2 from Stefan Kientzler
Hi Stefan

I should have started my last comment by saying thank you for uploading your work here. I feel like I'm very close to understanding and using it.

When I subscribe to push notifications it works successfully. The database has a record there and when I view PNTestPushSingle.php there is a log:

fcm.googleapis.com: The request to send a push message was received and accepted.

And count of subscriptions = 1.

But I have never actually seen a notification pop up. And I can't seem to send any additional notifications. If I refresh PNTestPushSingle.php, nothing happens.

The code inside PNTestPushSingle.php suggests it should send a notification saying "...first text to display" and/or an elephant.png image.

But I haven't seen or received any such notifications.

Basically, after setting it all up and subscribing to notifications and having that succeed. I don't actually know how to send a notification

  4. Re: How to send notification after...   Reply   Report abuse  
Picture of john doe john doe - 2023-06-02 16:02:23 - In reply to message 2 from Stefan Kientzler
Just to add...

My understanding is that the PNTestServer.php file goes through all records in the database and sends the same push notification to them all. The PNTestPushSingle.php file just sends to one. Is that correct?

What I don't understand is if there are multiple records in the DB then which one would PNTestPushSingle.php send to?

Also I was expecting to see a visible popup window or something that displayed the notification but I haven't seen anything.

I also expected a new notification to be sent each time I ran PNTestPushSingle.php but after the first time I run it nothing happens after.

My final query is, how do I actually get multiple records in the database? When I subscribe in the browser on my PC it successfully logs the subscription but If I do the same thing on my phone nothing happens. Also if I do the same thing in a different browser on my PC nothing happens.