简体   繁体   English

FCM Cloud Messaging 与 Notifications 和 Message 的区别

[英]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.

相关问题 在Firebase Cloud Messaging上检查新通知。 (FCM) - Check for new notifications on Firebase Cloud Messaging. (FCM) 如何向FCM(Firebase云消息传递)令牌的特定用户发送消息? - How to send a message to a specific user of an FCM (Firebase Cloud Messaging) token? 是否可以在没有 Firebase Cloud Messaging (FCM) 的情况下向所有安装了我的应用程序的设备发送推送通知? - is it possible to make push notifications to all devices which had installed my application without Firebase Cloud Messaging (FCM)? addCompleteListener()尚未解决-Firebase Cloud Messaging(FCM) - addCompleteListener() is not being resolved - Firebase Cloud Messaging (FCM) MismatchSenderId错误Firebase云消息传递(FCM) - MismatchSenderId error Firebase Cloud Messaging (FCM) Firebase Cloud Messaging(FCM)无法获取数据 - Firebase Cloud Messaging (FCM) not getting data 带有Google Cloud消息传递的android推送通知库 - android push notifications library with google cloud messaging 如何在我的应用从 Play 商店中删除之前修复暴露的 Firebase 云消息 (FCM) 服务器密钥? - How to fix exposed Firebase Cloud Messaging (FCM) server keys before my app gets removed from Play Store? 调用“ https://fcm.googleapis.com/fcm/send”时,Firebase云消息传递出现内部服务器错误 - Firebase cloud messaging getting internal server error when calling “https://fcm.googleapis.com/fcm/send” 无法接收来自对讲机、FCM 的推送通知 - Cant receive push notifications from Intercom, FCM
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM