karns
karns

Reputation: 5867

Progressive Web App Notification When Clearing Tasks/Killing App

I've been experimenting with Progressive Web Apps (PWA) and using service workers to create native Notifications on phones (like a Galaxy s7/s8).

All has been working great if the page/PWA is open or in the background/tasks (super slick :D), but one thing I've noticed is that if it is killed via the task manager, the notifications no longer work.

This seems to be the case whether I'm using the web app in the browser or if I add it to home page using the PWA functionality.

Here is a snippet of a simple piece of logic in case it helps:

        if (Notification.permission === 'granted') {
            navigator.serviceWorker.ready.then(function(serviceWorker) {
                serviceWorker.showNotification('You have new notifications!');
            });
        }

Questions

1) Is this an inherent limitation of PWA's?

2) Is there a workaround (like auto-starting the app, perhaps)?

Upvotes: 2

Views: 1092

Answers (1)

oninross
oninross

Reputation: 999

All has been working great if the page/PWA is open or in the background/tasks (super slick :D), but one thing I've noticed is that if it is killed via the task manager, the notifications no longer work.

I beg to differ. I have created a PWA for a bus app and even if I kill the app, I still receive the notification.

To answer your questions:

  1. iOS is the biggest limitation as of the moment. The idea of having a PWA is to behave and look like an app. Having push notifications and offline caching is one of the things driving a PWA to be successful and not build an app.
  2. There is no such thing as an auto-start. If the user has landed on the page and the SW has installed properly, it is already "listening" in the background.

Upvotes: 1

Related Questions