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

查看:67
本文介绍了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\nodejs\node.EXE

npm: 6.4.1 - C:\Program Files\nodejs\npm.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.

阅读以了解更多详细信息.

Read this for more details.

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

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