Firebase Cloud Messaging Subscribe Multiple Tokens

2019-05-29 10:00发布

I have an app that allows users to create an account. I then store user information in the Firebase Database. I also store all of the users device tokens in case they are using multiple devices with one account (iPhone, iPad, Android, etc).

When a user subscribes to a topic, I would like to be able to subscribe all of their associated device tokens to that topic and not just the device they are currently using. Is there a way to specify a token when subscribing to a topic so that they will receive topic notifications on all of their devices.

1条回答
我想做一个坏孩纸
2楼-- · 2019-05-29 10:01

I also store all of the users device tokens in case they are using multiple devices with one account (iPhone, iPad, Android, etc).

I'm presuming from that statement, that you are using Device Groups.

When a user subscribes to a topic, I would like to be able to subscribe all of their associated device tokens to that topic and not just the device they are currently using. Is there a way to specify a token when subscribing to a topic so that they will receive topic notifications on all of their devices.

The way I'm thinking of how to do this, is via your server side. Check the connected tokens to your device group, then subscribe the tokens using the batchAdd.

What I'm not sure is, if it is possible to Subscribe a notification_key to a Topic though.

查看更多
登录 后发表回答