2

With GCM, when user expresses their preference whether they are willing to get notifications, we could mark their preference as active or inactive

How can I achieve similar effect with FCM?

When user says they don't want to receive pushes, we'd have to unsubscribe the user from all the topics we have?

Are there better approaches?

KENdi
  • 7,576
  • 2
  • 16
  • 31
eugene
  • 39,839
  • 68
  • 255
  • 489

1 Answers1

0

Depending on the scenario, unsubscribing from the topics is the way to go.

However, if your goal is to simply prevent the user from seeing any push notifications appearing on their screen, a workaround I could think of is have a setting (e.g. enable/disable notifications) that identifies if you should/shouldn't display a notification every time the user receives one.

For example, user installs the app. Initially, the setting defaults to enabled. Push notifications are displayed normally. If user disables it, when the device receives the message, you do not create a notification display.

For this to work, I'm thinking the checking should be done inside the method where you create the notification (e.g. sendNotification).

So the scenario now is that the device is still technically receiving the notification, it's just that you're not showing/displaying it to the user.

Note: I haven't tried to go with this scenario myself, so I'm not sure if this is breaking any best practices. I would still go with the unsubscribing if it were me though. It's easier.

AL.
  • 36,815
  • 10
  • 142
  • 281