Push Notification data is always null

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  >  Push Notification data is always null  >  (Un) Subscribe thread alerts  
Subject:Push Notification data is always null
Summary:Maybe I missed something unspoken in setup
Messages:2
Author:Daniel Masi
Date:2020-08-27 01:44:32
 

 


  1. Push Notification data is always null   Reply   Report abuse  
Picture of Daniel Masi Daniel Masi - 2020-08-27 01:44:32
I receive the push notification within the service worker, however, the data property is always empty. I'm setting the title and body for the payload. Have the public/private keys and auth from the subscription. The only thing I can think of is that I haven't setup an SSL cert for the site. Would this have an impact?

  2. Re: Push Notification data is always null   Reply   Report abuse  
Picture of Stefan Kientzler Stefan Kientzler - 2020-08-27 14:34:47 - In reply to message 1 from Daniel Masi
Hello Daniel,

i am a bit surprised that the subscription worked at all outside of a secure context (SSL/HTTPS), since the JS Push API normally only works then (see also section 2.1.1. in my tutorial).

I myself do not have any constellation without SSL in which I can even create a subscription - so unfortunately I cannot say how or which data is transmitted in such a case. From my point of view it surely can be one possible effect, that the entire payload of the message is not transferred then.

So i think you first should try it in an environment with secure context.

regards Stefan

 

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