在Firebase Cloud Functions中尝试使用Firebase Cloud Messaging发送推送通知时,找不到请求的实体 [英] Requested entity was not found when trying to send a push notification using Firebase Cloud Messaging in Firebase Cloud Functions

查看:633
本文介绍了在Firebase Cloud Functions中尝试使用Firebase Cloud Messaging发送推送通知时,找不到请求的实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过FCM从Firebase Cloud函数通过以下代码发送多播通知:

I'm trying to send a multicast notification via FCM from a Firebase Cloud function with the following code:

const message = {
    tokens: recipients,
    notification: {
        title: title,
        body: body
    },
    data: {
        projectPartnerId: projectPartnerId
    }
};
return admin.messaging().sendMulticast(message);

并且没有发送任何推送通知.每个响应都包含一条错误,并带有相同的消息:未找到请求的实体".

And none of the push notifications is getting sent. Each response contains an error with the same message: "Requested entity was not found".

我在Google Cloud控制台中启用了该API(Firebase文档中的任何地方都未提及,但显然这是必需的).我不知道还能做什么.我可以找到的所有其他问题都与HTTP API或旧版API有关.我正在使用最新版本的Firebase Admin SDK.

I enabled the API in the Google Cloud console (which was not mentioned anywhere in the Firebase documentation but apparently that was necessary). I don't know what else I can do. And all the other questions I could find related to the HTTP API or the legacy API. I'm using the latest version of the Firebase Admin SDK.

推荐答案

弄清楚了.因此很明显,当我尝试发送的FCM令牌不再注册时,就会发生此错误,如"messaging/registration-token-not-registered"错误代码所证明的.在那种情况下,我只需要从用户的令牌中删除该令牌并完成它即可.

Figured it out. So apparently, this error happens when the FCM token I'm trying to send to is not registered anymore, as evidenced by the "messaging/registration-token-not-registered" error code. In that case I just need to remove this token from the user's token and be done with it.

这篇关于在Firebase Cloud Functions中尝试使用Firebase Cloud Messaging发送推送通知时,找不到请求的实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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