我在多台设备上安装了我的 Android 客户端应用程序.我还有我的服务器应用程序,可以向这些应用程序发送消息.问题是某些设备会收到消息而其他设备不会.将消息发送到这些设备时,我收到错误MismatchSenderId".
I have my client app with Android installed in several devices. I also have my Server app that send messages to those apps. The problem is that some devices receive the messages and other don't. I get the error "MismatchSenderId" when sending the message to those devices.
我划分了问题,所以我打开了 firebase 控制台并向我的应用程序发送通知(我有每个应用程序的令牌).因此,使用控制台应用程序,我在使用我的服务器的相同设备上遇到错误.但正如我所说,每台设备都在使用同一个应用程序.
I divided the problem, so I open the firebase console and send notifications to my apps (I have the Token for each of them). So, using the console app, I get errors on the same devices that using my server. But as I said, every device is using the same app.
原因有什么帮助吗?
首先,我要指出 MismatchSenderId
错误:
So to start of, I'd point out the description for MismatchSenderId
error:
注册令牌与特定的发件人组相关联.当客户端应用注册 FCM 时,它必须指定允许哪些发件人发送消息.在向客户端应用程序发送消息时,您应该使用其中一个发件人 ID.如果您切换到其他发件人,现有的注册令牌将不起作用.
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 并将其用于应用程序,从而使新令牌与新项目的 发件人 ID.正确地可视化它:
As per our discussion, it was pointed out that you created a new Firebase Project instead of importing your Google Project that you were using for GCM. From the new project, the google-services.json was generated and used for the app, which resulted for new tokens to be associated with the new Project's Sender ID. To visualize it properly:
GCM 注册令牌 > 仅接收来自 > Google Project (1st) 的消息
GCM Registration Tokens > only receive messages from > Google Project (1st)
New Tokens > 只接收来自 > Firebase Project (2nd)
New Tokens > only receive messages from > Firebase Project (2nd)
作为一种解决方案,我建议您将 Google 项目导入 Firebase 控制台,从该项目生成一个 google-services.json 并将您的应用中的那个替换为该项目,它将应用与该项目相关联(正确)项目.这反过来又创建了现在与您的第一个项目相关联的令牌.
As a solution, I advised for you to import the Google Project to the Firebase Console, generate a google-services.json from that Project and replace the one in your app with that, which associates the app to that (correct) project. This in turn created tokens that are now associated with your 1st Project.
GCM 注册令牌 > 只接收消息 > Google 项目(第一期)
GCM Registration Tokens > only receive messages > Google Project (1st)
新令牌 > 现在接收消息 > Firebase 项目(第 2 次) 导入的 Google 项目(第 1 次)
New Tokens > now receive messages > Firebase Project (2nd) Imported Google Project (1st)
希望这是有道理的.
很高兴在讨论中提及:
应用更改后,您提到错误仍然存在,但这是一个不同的问题,只需使用服务器密钥即可解决.
在讨论期间链接了帖子.
这篇关于Firebase FCM 不匹配SenderID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!