Web push notification limit

Hi, I'm testing the new web push notification feature introduced in iOS 16.4. I'm testing it in a PWA that I developed. Apparently all is working well. I can register the subscription and receive notifications. The problem is that I only receive the first three notifications sent. After receiving them, I don't receive any more until I subscribe again. Is there any limitation of notifications sent per hour or day with the same subscription token? Should I renew the subscribtion token in background frequently or it's not recommended?

Post not yet marked as solved Up vote post of hectorest Down vote post of hectorest
1.1k views

Replies

Hi, I was having the same problem. And I found out why. I found a sample code.

https://gist.github.com/dbushell/39e35d5fa5404dfe7b555e98f0194619

https://developer.apple.com/documentation/usernotifications/sending_web_push_notifications_in_safari_and_other_browsers

Safari doesn’t support invisible push notifications. Present push notifications to the user immediately after your service worker receives them. If you don’t, Safari revokes the push notification permission for your site.

"immediately" means you can't use Promise/async/await.

Unfortunately, Safari doesn’t work this program.

MyCode(ev) {
  const request = indexedDB.open("MyTestDatabase");
  request.onsuccess = (event) => {
    self.registration.showNotification('Push Message', {
      body: ev.data ? .text() ? ? 'no data';
    })
  };
}

self.addEventListener('push', (ev) => {
  ev.waitUntil(MyCode(ev));
});