zaru / webpush

webpush, Encryption Utilities for Web Push protocol
MIT License
396 stars 73 forks source link

Web push failed? only for chrome after succeed once #68

Closed kimyu92 closed 5 years ago

kimyu92 commented 5 years ago

I have created a simple web push demo. So far, I can send notification to firefox without problem.

However, I can only do it once for chrome for some unknown reasons.

The way I have setup:

Here is the dashboard from google console, in case it helps

google_console_fcm

Also, there was an issue mentioned about the gem would not work with jwt above v2? It would be great if anyone can clarify about this.

zaru commented 5 years ago

@kimyu92 Do you get an error when sending?

kimyu92 commented 5 years ago

@zaru There was no error when sending/receiving the message.

I have tweaked the rest of the code, to clarify things up, the latest webpush is actually working fine with JWT 2.

In order for notification to show up on chrome, I have to avoid passing tag to the notification options. I suspect chrome doesn't like the fact of using same tag?

self.addEventListener('push', function(event) {
  // ... within push callback
  event.waitUntil(
    self.registration.showNotification(title, {
      body: body,
      icon: icon,
      // tag: tag
    })
  );

Also, according to Can I use site, Microsoft Edge seems to support push api since v17. Does the gem support Microsoft Edge as well? 👈 It works!