Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save tw-Frey/2085da4c91ffc35c9584ead2d1094367 to your computer and use it in GitHub Desktop.

Select an option

Save tw-Frey/2085da4c91ffc35c9584ead2d1094367 to your computer and use it in GitHub Desktop.
接收來自多個發件人的消息 (Receiving messages from multiple senders)

原文

https://firebase.google.com/docs/cloud-messaging/concept-options#receiving-messages-from-multiple-senders

譯文

https://firebase.google.com/docs/cloud-messaging/concept-options?hl=zh-tw#receiving-messages-from-multiple-senders


Receiving messages from multiple senders

FCM allows multiple parties to send messages to the same client app. For example, suppose the client app is an article aggregator with multiple contributors, and each of them should be able to send a message when they publish a new article. This message might contain a URL so that the client app can download the article. Instead of having to centralize all sending activity in one location, FCM gives you the ability to let each of these contributors send its own messages.

To enable this feature, make sure you have each sender's sender ID. When requesting registration, the client app fetches the token multiple times, each time with a different sender ID in audience field, using the token retrieval method for the given platform:

Make sure that you do not add multiple sender IDs to a single token request, as this can have unpredictable results. Make each call separately, once per sender ID.

Finally, share the registration token with the corresponding senders, and they'll be able to send messages to the client app using their own authentication keys.

Note that there is limit of 100 multiple senders.


接收來自多個發件人的消息

FCM 允許多方向同一個客戶端應用程序發送消息。例如,假設客戶端應用程序是具有多個貢獻者的文章聚合器,並且每個貢獻者都應該能夠在發布新文章時發送消息。此消息可能包含一個 URL,以便客戶端應用程序可以下載文章。 FCM 無需將所有發送活動集中在一個位置,而是讓您能夠讓這些貢獻者中的每一個發送自己的消息。

要啟用此功能,請確保您擁有每個發件人的發件人 ID。請求註冊時,客戶端應用程序多次獲取令牌,每次在受眾字段中使用不同的發件人 ID,使用給定平台的令牌檢索方法:

確保不要將多個發件人 ID 添加到單個令牌請求中,因為這可能會產生不可預知的結果。分別撥打每個電話,每個發件人 ID 一次。

最後,與相應的發件人共享註冊令牌,他們將能夠使用自己的身份驗證密鑰向客戶端應用程序發送消息。

請注意,有 100 個多個發件人的限制。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment