简体   繁体   English

Fcm:当应用程序在后台和前台时向 Android 和 IOS 发送 DataMessage

[英]Fcm: Send DataMessage to Android and IOS when app is in background and in foreground

I'm implementing my custom FCM server for send notification to Android and IOS devices.我正在实现我的自定义 FCM 服务器,用于向 Android 和 IOS 设备发送通知。 I need to use DataMessage for send custom key value pair to both OS, and my data message is something like:我需要使用 DataMessage 向两个操作系统发送自定义键值对,我的数据消息类似于:

{
  "content_available": true,
  "data": {
    "lan": "IT",
    "messageId": "67",
    "message": "test message"
  },
  "registration_ids": [
    "..."
  ],
  "priority": "high"
}

Android receive correctly notification when app is in foreground and in background.当应用程序在前台和后台时,Android 会正确收到通知。 IOS receive data only when app is in foreground. IOS 仅在应用程序处于前台时接收数据。 What's wrong?怎么了?

I was pulling my hair out for the same thing, trying to make it work on both Android and iOS.我正在为同样的事情拉我的头发,试图让它在 Android 和 iOS 上都能运行。 Turns out you can't.事实证明你不能。

In Android, if it's data payload, it will works in background, and notification payload won't work in background.在Android中,如果是数据载荷,它会在后台工作,而通知载荷不会在后台工作。

In iOS, if you send notification payload, then it works in background, but data payload won't work in background.在 iOS 中,如果您发送通知有效负载,则它会在后台运行,但数据负载将不会在后台运行。 See this issue for more info 有关更多信息,请参阅此问题

Seems like you have to sacrifice one platform for other.似乎您必须为另一个平台牺牲一个平台。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 收到新的FCM消息(前景和背景)时,Android应用程序崩溃 - Android app crashes when receiving a new FCM message (foreground and background) 当应用程序处于前台或后台时如何使用 FCM 处理通知 - How to handle notifications with FCM when app is in either foreground or background 在前台在后台收到FCM通知时应用崩溃 - App Crashes when receiving FCM Notification on Foreground works on Background 当应用程序在前台而不是后台时,FCM通知,通知单击 - FCM notification, notification click when app is in foreground not background FCM:当应用程序处于前台状态时处理其应用程序的不同数据通知 - FCM : Handling different data notification of an android app when app is in foreground 无论应用是后台还是前台,均未收到FCM通知 - FCM notification not received whether the app in background or foreground 当应用程序在后台运行时,FCM的意图不起作用(android) - intent with FCM not working when app is in background(android) Android FCM:当应用程序在后台时 FCM 显示(通知)消息登录 - Android FCM: FCM display(notification) message loggin when app is in background FCM:我已使用FCM接收有关我的应用程序的通知。 当我的应用程序处于前台时,它将所有通知分组,但不将其组合到后台时 - FCM: I have used FCM to receive notification for my app. When my app is in foreground it groups all notifications but not when app is in background 当应用程序在前台时未收到FCM推送通知,但在应用程序在后台时收到 - FCM Push notification didn't receive when app is in foreground but receive when app in background
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM