GCM Topics or Downstream Messaging

前端 未结 1 1879
难免孤独
难免孤独 2021-01-25 21:00

I\'m trying to add GCM to my app which is one of those general social apps with feeds, posts, comments. Think facebook.

I read the post for Sending Messages to Topics: h

相关标签:
1条回答
  • 2021-01-25 21:40

    Topic vs. Downstream

    The "1 million subscriptions"-limitation really makes topic messaging more or less pointless. I only used it in an app with a rather small target group, there I use it for sending general notifications sent to all clients. In that particular use case it was very nice to have, because this way I did not have to care about saving registration ids.

    In your case, I think the target group will be larger, thus you will need downstream messages for most notifications in order to keep number of subscriptions within the limit.

    And, in case you have a webapplication too (like Facebook), then you would have to subscribe for the topic in your webapp as well, which is not possible as far as I know, but linking the post with your user´s normal id would not be a problem and via that you automatically would know the reg-ids of all users who liked/commented a post when someone else changes the post somehow.

    And one last hint on that: Think of a user who already commented a post and hence being a "subscriber" of that post. When you use topics and that user comments the post a second time he/she would get a notification that someone commented on the post (which is quite pointless) and you would not be able to exclude him/her from that notification triggered by him-/herself. Hence you would need a topic per user and per post which in turn would be quite the same like just using the user´s registration-Id.

    My conclusion: Topic messages are only helpful if you have a small app / target group and when using, you need to make sure that there is no way that a user could retrieve a notification with information he obviously won´t be interested in.

    Downstream Params

    As stated in the docs, to is used for a notifcation with either a single recipient or for topic notifications. As soon as you have multiple reg-ids you need the registration_ids. You will retrieve a server error from GCM when trying to trigger a notification with both params set:

    Must use either "registration_ids" field or "to", not both

    (Couldn´t find it in the docs, just tried it out)

    0 讨论(0)
提交回复
热议问题