android - Firebase FCM MismatchSenderID

标签 android firebase firebase-cloud-messaging

我在多台设备上安装了我的 Android 客户端应用程序。 我也有我的服务器应用程序,可以向这些应用程序发送消息。 问题是某些设备会收到消息,而其他设备则不会。 向这些设备发送消息时,我收到错误“MismatchSenderId”。

我把问题分开了,所以我打开 firebase 控制台并向我的应用程序发送通知(我有每个应用程序的 token )。因此,使用控制台应用程序,我在使用我的服务器的相同设备上遇到错误。但正如我所说,每台设备都在使用相同的应用程序。

有什么帮助吗?

最佳答案

首先,我要指出 MismatchSenderId 的描述错误:

A registration token is tied to a certain group of senders. When a client app registers for FCM, it must specify which senders are allowed to send messages. You should use one of those sender IDs when sending messages to the client app. If you switch to a different sender, the existing registration tokens won't work.

根据我们的讨论,有人指出您创建了一个新的 Firebase 项目,而不是导入您用于 GCM 的 Google 项目。从新项目中,生成了 google-services.json 并将其用于应用程序,这导致新 token 与新项目的 Sender ID 相关联。 .正确地可视化它:

  • GCM 注册 token > 仅接收来自 > Google 项目(第 1 个)的消息

  • 新 token > 仅接收来自 > Firebase 项目(第 2 个)的消息

作为一种解决方案,我建议您将 Google 项目导入 Firebase 控制台,从该项目生成一个 google-services.json 并将您的应用程序中的那个替换为那个,从而将应用程序关联到那个(正确)项目。这反过来又创建了现在与您的第一个项目相关联的 token 。

  • GCM 注册 token > 仅接收消息 > Google 项目(第 1 个)

  • 新 token > 现在接收消息 > Firebase 项目(第 2 个) 导入的 Google 项目(第 1 个)

希望这是有道理的。


在讨论中值得一提:

  • 应用更改后,您提到错误仍然存​​在,但这是一个不同的问题,只需使用服务器 key 即可解决。

  • 已链接 a post在讨论中。

关于android - Firebase FCM MismatchSenderID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43904189/

相关文章:

android - Firebase 云消息传递仅在 Android 上看到最后的通知

php - 使用 api 时未收到 Firebase 消息

android - 如何将 JNI 与 AAR 库一起使用?

java - 避免两次实现方法(已经扩展抽象类的类)

Android - 如何以编程方式检查当前是否启用了 Firebase Analytics?

java - 查询中的 Firebase 多个 WHERE 子句

android - Firebase 通知不显示使用 PHP

Android 在此图片之上绘制图片(动态)

android - 检测 2012 年之前生产的 Android 设备的最佳方法是什么?

Firebase 中的 JavaScript 变量仅出现在它调用的第二次函数中