firebase API中的MismatchSenderID错误 [英] MismatchSenderID error in firebase API

查看:1795
本文介绍了firebase API中的MismatchSenderID错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 FCM 为Android通知编写服务器端代码

I'm writing server-side code for android notification using FCM.

所以代码发送正确通知主题但不通知特定设备的注册令牌。
因此代码适用于这种情况 -

So the code sends the notification correctly to the topics but not to the particular device's registration token. So the code works fine for this case-

info.put("to", "topics/xyz"); 
info.put("title", "Hello 1");
info.put("body", "Hi");

但对于第二种情况 -

But for the second case-

info.put("to", DeviceIdKey.trim()); //device registration token
info.put("title", "Hello 1");
info.put("body", "Hi");

它给出,

输出

{
"multicast_id": 1XXXXXXX01820YYYY2,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [
        {
            "error": "MismatchSenderId"
        }
    ]
}

重要 - 和我所拥有的所有android / IOS设备的注册令牌是由GCM生成的2年。
谢谢!

IMPORTANT - And the registration tokens for all the android/IOS devices which I have are 2 years old generated by GCM. Thanks!

推荐答案

如果目标令牌未与发送消息的项目相关联,则会出现MismatchSenderId 错误(正如我在答案中提到的那样此处这里)。 意味着令牌已过期,如果是,您将收到 NotRegistered 错误。

MismatchSenderId error occurs if your target token is not associated to the project that is sending the message (as I mentioned in my answers here and here). It does not mean that the token is expired, if it were, you would receive a NotRegistered error instead.

一般情况下,GCM令牌仍应与FCM兼容(请参阅我的回答此处),如果发件人与令牌相关联(如果您只是 导入 您的项目到Firebase控制台,那么它仍然可以收到该消息,那么它应该没问题。)

In general, GCM tokens should still be compatible with FCM (see my answer here), they could still receive the message, provided that the sender is associated with the token (if you simply import your project to Firebase Console, then it should be fine).

这篇关于firebase API中的MismatchSenderID错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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