PHP Classes

Help with implementation

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  >  Help with implementation  >  (Un) Subscribe thread alerts  
Subject:Help with implementation
Summary:A little confused over the next step
Messages:10
Author:Jeff Kurzner
Date:2020-05-13 14:40:55
 

  1. Help with implementation   Reply   Report abuse  
Picture of Jeff Kurzner Jeff Kurzner - 2020-05-13 14:40:55
Thanks for providing this library as it was something I was hoping to implement. I have read through the materials and uploaded to my site to try and implement. I am a little confused over the sample pages and what happens or what the process is to implement once the PHP pages and library have been uploaded. I did update the VAPID sections but not sure how to test. I am using the sqlite version. When I attempt to run the pntestclient it shows:

Welcome to PUSH Notifications Client
Subscribe PUSH Notifications

Unregister Service worker

Update Service worker

PUSH Notifications are subscribed

Secure context: true
Notification: defined
PushManager: defined
serviceWorker: defined
Notification.permission: granted

When I then go to the pntestserver page I get the following log note:

Push - Log:
fcm.googleapis.com

Payload encrypting error: openssl: error:02001003:system library:fopen:No such process
resonse code: ()

Can you try to point me in the right direction?

  2. Re: Help with implementation   Reply   Report abuse  
Picture of Stefan Kientzler Stefan Kientzler - 2020-05-13 17:38:11 - In reply to message 1 from Jeff Kurzner
Hi jeff

your first question is quite easy to answer. With the PNTestClient.html page you can quickly and easily register the first subscription on your server - you also want to see what messages you send ;-)
Since the page shows 'PUSH Notifications are subscribed', you have already done so.

The second question is a little more difficult. This is obviously a problem with the OpenSSL configuration of your server (unfortunately you do not write what kind of server and which environment you are working on - so i can't really help you ).

Search the internet for
'openssl config failed: error: 02001003: system library: fopen: No such process'
to find solutions to this problem.

Please keep me up to date and if you have solved the problem, please post the solution (including your server type and configuration if possible) here,

Regards, Stefan

  3. Re: Help with implementation   Reply   Report abuse  
Picture of Jeff Kurzner Jeff Kurzner - 2020-05-13 18:18:07 - In reply to message 2 from Stefan Kientzler
Hey Stefan,

Thanks for the quick follow-up. I am using a shared host Windows IIS that I do not control. I have reached out to the hosting company and attached the following link to see if it was something on their end.
stackoverflow.com/questions/5218822 ...

  4. Re: Help with implementation   Reply   Report abuse  
Picture of Jeff Kurzner Jeff Kurzner - 2020-05-14 13:34:14 - In reply to message 3 from Jeff Kurzner
I believe I have solved the problem (Well, actually the fine support tech at midphase did) and it was related to the OPENSSL configuration as outlined in the StackOverflow thread.

Defining OPENSSL_CONF in the PHP settings did not solve the problem nor did setting it in the PHP script. What eventually he had to do was to create a global openssl config file in the web's root user c:\usr\local\ssl\

Now that it is functioning, I have one more question? Why is the notification that is generated on my computer different from the notifications of other websites? In windows 10 the notification seems to be within the Chrome browser and not a part of the OS? Is that something I missed from the documentation?

  5. Re: Help with implementation   Reply   Report abuse  
Picture of Stefan Kientzler Stefan Kientzler - 2020-05-14 15:46:47 - In reply to message 4 from Jeff Kurzner
Hi jeff

Nice to read that your problem is solved :-)
In my description you will find a few notes regarding the display of notifications in the appendix:

3.2. Standardbrowser settings to display notifications
Most (desktop) standard browsers offer the option of setting whether a service provided by the operating system or an own implementation should be used to display the notifications.

3.2.1. Firefox
Type 'about:config' in the navigation field for the Internet URL and search for 'alerts'. The value 'alerts.useSystemBackend' controls the behaviour. If set to true, notifications are displayed by the operating system, otherwise the browsers internal implementation is used to display the notifications.

3.2.2. Google Chrome
Enter 'chrome://flags' in the navigation field for the Internet URL and then search for 'notifications'. The setting 'Enable native notifications' controls the output.

3.2.3. Microsoft Edge
Since the Edge Browser is very much integrated into the Windows operating system, it basically uses the Control Center to display the notifications.

In addition, notifications from other websites may use their own implementation and not the standard notification API used here. The Notifications API or Web Push API has not been supported by all common browsers for too long, which is why some vendors still uses their own or third-party solutions.


  6. Re: Help with implementation   Reply   Report abuse  
Picture of Jeff Kurzner Jeff Kurzner - 2020-06-26 22:20:15 - In reply to message 5 from Stefan Kientzler
Hey Stefan,

Had to stop work on this implementation a few weeks ago and am just getting back to it. One thing I am having a real hard time trying to figure out seems to be why I can subscribe and unsubscribe to notifications, but those changes are not showing up in the database?

The pntestclient.html page will seemingly change the status of my notification subscription, but not update the database. It has to be holding those values someplace?

The values of the msg show that secure context is true; notification is defined, push manager is defined, service Worker is defined, Notification.permission is granted and PUSH Notifications are subscribed. However, the sqllite database is empty. Is the Notification information stored someplace outside of the database?

I can be reached outside the forum at jkurzner at mindshaft.com

Thanks

  7. Re: Help with implementation   Reply   Report abuse  
Picture of Stefan Kientzler Stefan Kientzler - 2020-06-27 08:30:23 - In reply to message 6 from Jeff Kurzner
Hi Jeff

apparently you have a problem with the connection between the service worker (PNServiceWorker.js) and your server.
To narrow this down, you first have to check in the console of your browser whether there appears any error when subscribing notifications. (when unsubscribing, no connection to the server is established - the server only gets this information when trying to send a notification to this client ...)

Open the page PNTestClient.html in the browser and then open the developer tools (depending on the browser this call differs). Next just click the 'Subscribe' Button. Either you directly get a message in the console or you may need to debug the service worker to isolate the problem.
(To the topic of 'Debugging the service worker' you can find some comments in my blog under 3.3.)

If everything works correctly in the service worker, then the problem must be on the server side in PNSubscriber.php.

  8. Re: Help with implementation   Reply   Report abuse  
Picture of Jeff Kurzner Jeff Kurzner - 2020-06-27 14:33:29 - In reply to message 7 from Stefan Kientzler
Thanks for the help Stefan. Once I used the browser application tool to clear the site data, the notifications seem to be working again. I suppose there was a disjointed connection between the data and my pages during development and testing.


  9. Re: Help with implementation   Reply   Report abuse  
Picture of Jeff Kurzner Jeff Kurzner - 2020-06-27 16:31:53 - In reply to message 8 from Jeff Kurzner
Is there a way to send a confirmation notification to only a new subscriber? For example if someone new signs up for push notifications, a way to let them know if was successful without sending a notification to all devices subscribed?

  10. Re: Help with implementation   Reply   Report abuse  
Picture of Stefan Kientzler Stefan Kientzler - 2020-06-28 15:29:26 - In reply to message 9 from Jeff Kurzner
Hi Jeff

You can solve this function on the server side in various ways by expanding the data provider.

The easiest way is probably to insert a 'hook' in the PNDataProvider::saveSubscription method, in which the corresponding greeting is sent after a successfull subscription.

The following way would also be conceivable:
- Add new data field 'bWelcomeSent' to the DB table
- Set the field in PNDataProvider::saveSubscription to FALSE
- Add a method selectForWelcome() to the extended Dataprovider class, which selects all data records with bWelcomeSent = FALSE
- Send them the appropriate greeting
- Set all bWelcomeSent from FALSE to TRUE after welcome sent

Sending a welcome message is a good idea. I will think about it myself a little bit and maybe add a corresponding function to the package.
If you have implemented such a function by yourself, it would be great if you could send me your solution so that I can integrate it accordingly.