我在多台设备上安装了我的 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/