[英]FCM Cloud Messaging difference from Notifications and Message
I implemented my backend service (using java and FCM) to send push-notifications to mobile apps.我实现了我的后端服务(使用 java 和 FCM)向移动应用发送推送通知。
I implemented my service using Java Firebase Admin-SDK ( https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/messaging/package-summary and https://firebase.google.com/docs/cloud-messaging/send-message#java ) about this and I'm able to send (and receive) push notifications on iOS and Android mobile apps. I implemented my service using Java Firebase Admin-SDK ( https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/messaging/package-summary and https://firebase.google .com/docs/cloud-messaging/send-message#java ),我能够在 iOS 和 Android 移动应用程序上发送(和接收)推送通知。
Now I received a request from mobile-developers that they needs to customize (client-side) the received push notifications (also when the app is in background mode).现在我收到了来自移动开发人员的请求,他们需要自定义(客户端)接收到的推送通知(同样当应用程序处于后台模式时)。
Probably here is reported a same question: What is the difference between Firebase push-notifications and FCM messages?可能这里报告了同样的问题: Firebase 推送通知和 FCM 消息有什么区别?
Reading the documentation ( https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages ) I understood that It's necessary to use a Data-message instead of a Notification message.阅读文档( https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages )我了解到有必要使用数据消息而不是通知消息。
It's not clear for me what's necessary to change to support this delivery type.我不清楚需要更改哪些内容才能支持这种交付类型。 Do I change the Android-config of the FCM-message or Do I remove some unnecessary data (just set all info into the custom data without others info for example Android configuration etc..)
我是更改 FCM 消息的 Android 配置还是删除一些不必要的数据(只需将所有信息设置到自定义数据中,没有其他信息,例如 Android 配置等)
It's possible to have a small example?可以举个小例子吗?
If your json will have notification
key, developers will not able to handle notifications in background.如果您的 json 将有
notification
密钥,开发人员将无法在后台处理通知。 They will receive this notification only when app is in foreground.只有当应用程序处于前台时,他们才会收到此通知。 In case when developers should receive “silent pushes” or they need control all notifications, you should remove
notification
key, and use only data
key.如果开发人员应该收到“静默推送”或者他们需要控制所有通知,您应该删除
notification
键,并且只使用data
键。
This can be achieved by changing the key 'notification' to 'data' as follows:这可以通过将关键“通知”更改为“数据”来实现,如下所示:
{
"notification": { //replace this line by "data"
"title": "Hey Gajanan",
"body": "Thanks for visiting omnidecoder.com"
},
"to" : "YOUR-GENERATED-TOKEN"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.