Hi Emil,
Yes, everything related to the service worker must be re-implemented in
order to upgrade to Angular 5. In Angular 4 there was no official way to
do it and the form I chose ended up not being the definitive one.
Apparently the Angular team doesn't go at the same speed as the Google
people, who advertised PWA everywhere without having a solution to
develop them.
Changing the push notification payload is not difficult. In order to
send the notifications we use a kind of gateway, to which kamailio sends
a simple HTTP post request and the server is in charge of giving it
notification form, searching for the user's tokens, etc.
The code is this https://github.com/saycel/webpush-server
As this server acts as an intermediary between Kamailio and the PWA, it
will not be necessary to make any changes in Kamailio. It's just a
change in how the response json is formed
(https://github.com/saycel/webpush-server/blob/dac9ef53355dd87a73529cf8a061af25b425b60f/index.js#L162)
Personally, I think it's best to re-implement our service worker.
Forcing a custom solution on libraries that are already deprecated does
not seem to have much future.
I hope that this answer will be useful and not too late. I thought I was
on the mailing list but I was wrong. I'm subscribed now.
Cheers, Marcos.
El 01/03/18 a las 11:15, Emil Kroymann escribió:
Hi list, hi Marcos,
I started updating webph.one to Angular 5. My work in progress can be
viewed at github.com:ekroymann/webph.one.git.
I started with following the instructions
at https://angular-update-guide.firebaseapp.com/w. This is mostly
done. There are some new optional features, which we might want to
start using. I did not get into this yet.
It seems, that the material design dependencies still need to be
upgraded, since when compiling I get warnings about incompatibility.
However, the main problem is the service worker used for push. The
previous implementation relied on extending
@angular/service-worker@^1.0.0-beta.16, a pretty old version as we can
see. This version is not compatible anymore with Angular 5. The new
version of @angular/service-worker has a completely different
interface and also does not allow extension anymore. The extension of
the previous version implemented receiving the push notification and
displaying a notification to the user. The new version of
@angular/service-worker comes with a generic service worker, that has
built in support for receiving push notfications and displaying
notifications to the user.
BUT: this relies on the backend sending a notification payload to be
displayed as is in the push notification.
We now have two options: either implementing the ServiceWorker
completely our selves and not using @angular/service-worker, or
changing the backend to include the notification payload in the push
notifications.
I can work on this, but I wanted to know what is the preferred way to
go forward. I think, when changing the backends, we will have some
problems with testing, since we need a new version of the backend
deployed somewhere, along with the old version of the backend for the
previous versions of the app.
What is your opinion?
Cheers!
Emil