MatthieuLemoine / electron-push-receiver

A module to bring Web Push support to Electron allowing it to receive notifications from Firebase Cloud Messaging (FCM).

Home Page:https://medium.com/@MatthieuLemoine/my-journey-to-bring-web-push-support-to-node-and-electron-ce70eea1c0b0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shutting down and restarting push receiver

JohannRosenberg opened this issue · comments

In my app I have a sign-in screen. When the app starts, the push-receiver gets started and after the user signs in is able to receive push notifications. When the user signs out, the app is still running and the user is presented with the sign-in screen. However the push receiver was already registered and still receives notifications. I want to avoid that. I don't want to receive any push notifications when the user is not signed in. There are a few solutions I can see:

  • Store the notifications when they arrive and then process them after the user signs in. The bad thing about this is security. If someone had access to the app other than the rightful user, they would have access to the push notifications, although these could be encrypted. Storing and recalling these notifications is a lot more work.
  • Use some Javascript api to terminate the running instance of the push receiver when the user signs out and then restart it when the user signs back in.
  • Modify your push receiver code to destroy the tls connection when the user signs out and then recreate it when they sign back in.
  • Call the receiver's setup method from the web page that gets loaded AFTER the user signs in. Maybe this is the best solution?

Any suggestions on this? Thanks!