Home  >  Article  >  Backend Development  >  Send FCM with a combination of topic and device tokens

Send FCM with a combination of topic and device tokens

王林
王林forward
2024-02-10 10:33:161101browse

通过主题和设备令牌的组合发送 FCM

php Editor Xigua will introduce you to a method of sending FCM (Firebase Cloud Messaging) through a combination of theme and device token. FCM is a cross-platform messaging service that can be used to send notifications to mobile devices and browsers. By using a combination of topic and device tokens, we can more flexibly send notifications to specific users or user groups to achieve more precise push. In this article, we will explain in detail how to send FCM messages in this way so that developers can better take advantage of this feature.

Question content

I'm trying to handle a use case where the user can turn on/off to receive notifications from many scenarios.

I think every scene is a theme. I'm using go sdk and I see that the Message structure has both Token and Topic. So does this mean I can send FCM with a combination of topic and device token lists?

Workaround

As far as I know, there is no way to combine the token and topic in a single request to the FCM API to send a message. The closest you can get is to make batch requests, with one request for the topic and one or more for the token.

To allow the user to turn off notification display, consider sending data messages (instead of automatically displayed notification messages) and then handling the display or non-display of these messages in the client application code.

The above is the detailed content of Send FCM with a combination of topic and device tokens. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete