PushPad: Chrome doesn't display push-notificat

2019-09-13 02:15发布

问题:

This question results from following question (see comment section):

PushPad: Subscribe is removed after site refresh

I've got a problem using PushPad. I've created a project, implemented the code and so on. My problem is that Chrome does not display push-notifications I sent (desktop and mobile version). Using Firefox everything works fine. I get notifications displayed in the second I sent them.

After some time, I found the Function "Emulate Push Event" in the Chrome Developer Tool (Ressources->Service Worker). When I clicked this button, the push-notifications I sent before were displayed by Chrome.

So the push-notifications seem to be send by PushPad and are received, but not displayed automatically, as if they are queued by the Service Worker? But my website users should not have to go into the Developer Console and click that button to receive the notifications (it should be like it is in Firefox).

I've already tried to use my "Project ID" and also my "Project Number" (from my Google Project) as my GCM Sender ID. Both result in the issue described above. And also I've generated a new API-Key and changed it in my Pushpad-Project but nothing changed.

I also noticed that the same issue results, when I use the Pushpad DEMO to send a demo-notification from the official Pushpad-Homepage. It is also queued and only displayed when I press the button in Developer Console.

I have tried all my tests on 2 different PC's and one Nexus 4 with Chrome, and it's always the same problem.

Do you have any suggestions? Maybe (just a guess) some issue with the Service Worker provided by Pushpad (as it is the same on their HP)?

回答1:

I've already tried to use my "Project ID" and also my "Project Number" (from my Google Project) as my GCM Sender ID

In the manifest you must use the Project number (it looks like 100228559515) as described here: https://pushpad.xyz/docs/pushpad_pro_requirements

Also check that the GCM api key that you have set in the project settings is correct. The issue is probably that (if that is wrong, GCM doesn't forward the push event to the browser and this would explain why everything works with Firefox and not with Chrome).

Regarding the Pushpad Demo I cannot reproduce the issue. Everything seems to work correctly with Chrome.



回答2:

I have found out that I had inserted the wrong HTTP-Referrer in the Credentials of my Google GCM API. Therefore the notifications were not displayed.