0

My Android client app does not receive any Firebase push notifications targeting topics, however I immediately receive notifications sent to all app users or notifications sent to specific devices.

I didn't change anything in my code and I checked whether the client is correctly subscribed to topics.

For further details about my subscription logic:

In order to make it easy for my web service to send notifications to a specific user, each user is subscribed to a topic entitled with his user-id whenever he logs in from the client app.

Is this approach weak somehow? Should I otherwise register the device token to my database every time it's updated? And then send the notification to that specific token?

AL.
  • 36,815
  • 10
  • 142
  • 281
AymanKun
  • 241
  • 1
  • 4
  • 20

1 Answers1

1

Should I otherwise register the device token to my database every time it's updated? And then send the notification to that specific token?

It is highly suggested that developers save the generated registration token for each device for later use. As mentioned in the docs:

After you've obtained the token, you can send it to your app server and store it using your preferred method.

In your case, it is preferable. It'll remove the added action of subscribing the device to a topic. Plus it can be useful to track the message status using Diagnostics tool should you need it in the future.

AL.
  • 36,815
  • 10
  • 142
  • 281
  • Indeed, identifying clients by their device token instead of topics gives more advantages and details about the message life cycle and info on whether it was received or not. – AymanKun Dec 17 '16 at 17:00
  • 1
    @AymanKun Yup. Also, there is no way to trace messages that was sent through the Topics API. See [here](http://stackoverflow.com/a/39389049/4625829). – AL. Dec 18 '16 at 04:59