firebase 云消息没有看到小米设备 [英] firebase cloud messaging didn't see xiaomi devices

查看:31
本文介绍了firebase 云消息没有看到小米设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个反应原生应用程序.我想从 firebase 发送云消息,但我不能.我准备了项目并安装在我的设备上.其中一个是三星,另一个是小米.当我发送通知时,我可以在我的三星上看到,但在小米上看不到.我也可以使用 fcmToken 发送通知我的虚拟 android 设备.你想我该如何解决这个问题?

I'm building an react native app. I want to send cloud messages from firebase but i can't. i prepared project and install on my devices. one of them samsung other one is xiaomi. when i send notification i can see on my samsung but not xiaomi. also i can send notification my virtual android device with fcmToken. do you want how can i fix that problem?

firebase 云消息控制台:https://pasteboard.co/IxyD0p3.png

firebase cloud messagin console: https://pasteboard.co/IxyD0p3.png

System:

OS: Windows 10

CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz

Memory: 1.46 GB / 7.89 GB

Binaries:

Node: 10.15.3 - C:Program Files
odejs
ode.EXE

npm: 6.4.1 - C:Program Files
odejs
pm.CMD

IDEs:

Android Studio: Version 3.3.0.0 AI-182.5107.16.33.5314842

react-native-cli: 2.0.1

react-native: 0.60.5


app/build gradle dependencies
implementation "com.google.android.gms:play-services-base:16.0.0"
    implementation 'com.google.android.gms:play-services-gcm:16.0.0'
    implementation "com.google.firebase:firebase-core:16.0.9"
    implementation "com.google.firebase:firebase-messaging:19.0.0"
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    implementation 'me.leolin:ShortcutBadger:1.1.21@aar'

/build gradle
classpath("com.android.tools.build:gradle:3.4.1")
        classpath('com.google.gms:google-services:4.3.2')

推荐答案

FCM 通知有两种类型:通知消息数据消息.

There are 2 types of FCM notifications: Notification message and Data message.

通知消息如下所示:

{
  "message":{
    "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "notification":{
      "title":"Portugal vs. Denmark",
      "body":"great match!"
    }
  }
}

并触发 FirebaseMessagingService 的 OnMessageReceaved() 方法.许多设备(尤其是华为和小米)试图尽一切努力终止后台服务以防止电池耗尽.所以 FirebaseMessagingService 并不是处理通知的最佳方式.

and triggers method OnMessageReceaved() of FirebaseMessagingService. Many devices (especially Huawei and Xiaomi) try to do everything to kill background services to prevent battery drain. So the FirebaseMessagingService isn't the best way to handle notifications.

第二种是
数据信息:

{
  "message":{
    "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "data":{
      "Nick" : "Mario",
      "body" : "great match!",
      "Room" : "PortugalVSDenmark"
    }
  }
}

此类型由系统托盘处理,因此您不需要运行任何服务来获取通知.它更方便的方法,但据我所知,它无法通过控制台实现.

This type is handled by the system tray, so you don't need any of service running to get the notification. Its much more convenient method, but as far i know, it can't be achieved with the console.

您可能需要服务器 API 来发送数据消息.

You would probably need server API to send Data message.

阅读了解更多详情.

这篇关于firebase 云消息没有看到小米设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆