Tuom
Tuom

Reputation: 655

FCM group or token array?

I am new to FCM and I am looking for best way how to add cloud messaging to my project.

I need to send notification to user who could be logged on several devices. According to Firebase documentation, there are groups for this purpose:

Typically, "group" refers a set of different devices that belong to a single user.

But according to this, groups are not supported by the most up to date HTTP v1 API.

Should I consider groups to be legacy too and rather send message to all of the stored tokens of user?

Upvotes: 2

Views: 1552

Answers (1)

Eran
Eran

Reputation: 393771

Groups are supported by both HTTP and XMPP protocols, as you can see in the first link you posted:

You can use device group messaging with the Admin SDKs, or by implementing the XMPP or HTTP protocols on your app server. The maximum number of members allowed for a notification key is 20.

Therefore you have no reason to consider groups as legacy.

This is also stated in the documentation of Downstream XMPP messages:

Downstream XMPP messages (JSON)

to Optional, string

This parameter specifies the recipient of a message.

The value can be a device's registration token, a device group's notification key, or a single topic (prefixed with /topics/). To send to multiple topics, use the condition parameter.

EDIT:

Seeing your question edit, you should use whichever protocol suits your requirements. The fact that FCM HTTP v1 is the most up to date API doesn't mean you have to use it, since it doesn't support some of the features supported by legacy HTTP and XMPP.

For example, if you want to use upstream messaging, you can't use FCM HTTP v1:

You'll need to decide on a way to interact with FCM servers: either using the Admin SDK or the raw protocols. Among the raw protocol options, the FCM HTTP v1 API is the most up to date, with more secure authorization and flexible cross-platform messaging capabilities. The legacy HTTP and XMPP server protocols area also available. Note that if you want to use upstream messaging from your client applications, you must use XMPP.

Similarly, if you decide to use HTTP v1 API, you'll have to send messages to the individual tokens of a given user.

Upvotes: 2

Related Questions