<small id='rcuSw'></small><noframes id='rcuSw'>

    1. <tfoot id='rcuSw'></tfoot>

      <i id='rcuSw'><tr id='rcuSw'><dt id='rcuSw'><q id='rcuSw'><span id='rcuSw'><b id='rcuSw'><form id='rcuSw'><ins id='rcuSw'></ins><ul id='rcuSw'></ul><sub id='rcuSw'></sub></form><legend id='rcuSw'></legend><bdo id='rcuSw'><pre id='rcuSw'><center id='rcuSw'></center></pre></bdo></b><th id='rcuSw'></th></span></q></dt></tr></i><div id='rcuSw'><tfoot id='rcuSw'></tfoot><dl id='rcuSw'><fieldset id='rcuSw'></fieldset></dl></div>
        <bdo id='rcuSw'></bdo><ul id='rcuSw'></ul>
      <legend id='rcuSw'><style id='rcuSw'><dir id='rcuSw'><q id='rcuSw'></q></dir></style></legend>
    2. Firebase admin SDK FCM 错误 需要主题、令牌或条件之一

      Firebase admin SDK FCM error Exactly one of topic, token or condition is required(Firebase admin SDK FCM 错误 需要主题、令牌或条件之一)
      <i id='8J0LQ'><tr id='8J0LQ'><dt id='8J0LQ'><q id='8J0LQ'><span id='8J0LQ'><b id='8J0LQ'><form id='8J0LQ'><ins id='8J0LQ'></ins><ul id='8J0LQ'></ul><sub id='8J0LQ'></sub></form><legend id='8J0LQ'></legend><bdo id='8J0LQ'><pre id='8J0LQ'><center id='8J0LQ'></center></pre></bdo></b><th id='8J0LQ'></th></span></q></dt></tr></i><div id='8J0LQ'><tfoot id='8J0LQ'></tfoot><dl id='8J0LQ'><fieldset id='8J0LQ'></fieldset></dl></div>
        <bdo id='8J0LQ'></bdo><ul id='8J0LQ'></ul>

            <tbody id='8J0LQ'></tbody>

          • <legend id='8J0LQ'><style id='8J0LQ'><dir id='8J0LQ'><q id='8J0LQ'></q></dir></style></legend>
          • <small id='8J0LQ'></small><noframes id='8J0LQ'>

            <tfoot id='8J0LQ'></tfoot>
              1. 本文介绍了Firebase admin SDK FCM 错误 需要主题、令牌或条件之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在修复发生的错误消息,但它以前也可以工作.我正在发送带有多个令牌的 FCM 通知并收到以下错误

                I am fixing an error message which occurred, but it also used to work before. I am sending FCM notification with multiple tokens and am getting the following error

                0|api      | 2020-2-11 13:26:26   [ExceptionsHandler] Exactly one of topic, token or condition is required
                0|api      |  +542752ms
                0|api      | Error: Exactly one of topic, token or condition is required
                0|api      |     at FirebaseMessagingError.FirebaseError [as constructor] (/var/www/tokee-api-new/node_modules/firebase-admin/lib/utils/error.js:42:28)
                0|api      |     at FirebaseMessagingError.PrefixedFirebaseError [as constructor] (/var/www/tokee-api-new/node_modules/firebase-admin/lib/utils/error.js:88:28)
                0|api      |     at new FirebaseMessagingError (/var/www/tokee-api-new/node_modules/firebase-admin/lib/utils/error.js:254:16)        0|api      |     at Object.validateMessage (/var/www/tokee-api-new/node_modules/firebase-admin/lib/messaging/messaging-types.js:46:15)
                0|api      |     at /var/www/tokee-api-new/node_modules/firebase-admin/lib/messaging/messaging.js:265:31
                0|api      |     at Array.map (<anonymous>)
                0|api      |     at Messaging.sendAll (/var/www/tokee-api-new/node_modules/firebase-admin/lib/messaging/messaging.js:264:29)
                0|api      |     at Messaging.sendMulticast (/var/www/tokee-api-new/node_modules/firebase-admin/lib/messaging/messaging.js:313:21)   0|api      |     at userChunks.forEach.userChunk (/var/www/tokee-api-new/src/modules/common/firebase/firebase.service.ts:154:42)     0|api      |     at Array.forEach (<anonymous>)
                0|api      |     at FCMService.<anonymous> (/var/www/tokee-api-new/src/modules/common/firebase/firebase.service.ts:142:16)
                0|api      |     at Generator.next (<anonymous>)
                0|api      |     at /var/www/tokee-api-new/dist/src/modules/common/firebase/firebase.service.js:13:71
                0|api      |     at new Promise (<anonymous>)
                0|api      |     at __awaiter (/var/www/tokee-api-new/dist/src/modules/common/firebase/firebase.service.js:9:12)
                0|api      |     at FCMService.sendToMany (/var/www/tokee-api-new/dist/src/modules/common/firebase/firebase.service.js:123:16)       0|api      |     at AdminNotificationController.<anonymous> (/var/www/tokee-api-new/src/modules/notification/admin-notification.controller.ts:65:42)
                0|api      |     at Generator.next (<anonymous>)
                0|api      |     at fulfilled (/var/www/tokee-api-new/dist/src/modules/notification/admin-notification.controller.js:16:58)
                0|api      |     at <anonymous> 
                

                产生错误的代码:

                async sendToMany(users: User[], notification: VSendNotification, title = 'Title', lowPriority = false) {
                    // We split emails into arrays of max. 100 size because of the limitation with FCM
                    const userChunks = _.chunk(users, 100);
                    const promises = [];
                    userChunks.forEach(userChunk => {
                      const msg: admin.messaging.MulticastMessage = {
                        notification: {
                          title,
                          body: notification.body
                        },
                        tokens: userChunk.map(user => user.firebaseToken),
                        android: {
                          priority: lowPriority ? 'normal' : 'high'
                        }
                      };
                      promises.push(this.app.messaging().sendMulticast(msg));
                    });
                    const result = await Promise.all(promises);
                    let accepted = 0;
                    let rejected = 0;
                    result.forEach(response => {
                      accepted += response.successCount;
                      rejected += response.failureCount;
                    });
                
                    return { accepted, rejected, notification };
                  }
                }
                

                想出了什么问题?

                推荐答案

                解决方案 - 避免向 Firebase 发送空的 fcm 令牌.

                Solution - Avoid sending empty fcm token to Firebase.

                我得到了解决方案.我列出了我所有的 firebase 令牌,我的数据库中有一些空令牌,这是主要问题.

                I got the solution. I listed all my firebase token and there were some empty tokens in my database which was the main problem.

                当我们发送空 fcm 令牌时,Firebase 给我们以下错误

                When we send empty fcm token, Firebase gives us below error

                Exactly one of topic, token or condition is required
                

                这篇关于Firebase admin SDK FCM 错误 需要主题、令牌或条件之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                quot;Status Code:200 OK (from ServiceWorker)quot; in Chrome Network DevTools?(“状态码:200 OK(来自 ServiceWorker)在 Chrome 网络开发工具中?)
                How to set a header for a HTTP GET request, and trigger file download?(如何为 HTTP GET 请求设置标头并触发文件下载?)
                Adding custom HTTP headers using JavaScript(使用 JavaScript 添加自定义 HTTP 标头)
                SQL Query DocumentDB in Azure Functions by an integer not working(通过整数在 Azure Functions 中 SQL 查询 DocumentDB 不起作用)
                Azure Functions [JavaScript / Node.js] - HTTP call, good practices(Azure Functions [JavaScript/Node.js] - HTTP 调用,良好实践)
                Azure Functions - Import Custom Node Module(Azure Functions - 导入自定义节点模块)
                1. <tfoot id='qLP9g'></tfoot>

                  <small id='qLP9g'></small><noframes id='qLP9g'>

                    <legend id='qLP9g'><style id='qLP9g'><dir id='qLP9g'><q id='qLP9g'></q></dir></style></legend>
                      <bdo id='qLP9g'></bdo><ul id='qLP9g'></ul>
                          <tbody id='qLP9g'></tbody>
                        • <i id='qLP9g'><tr id='qLP9g'><dt id='qLP9g'><q id='qLP9g'><span id='qLP9g'><b id='qLP9g'><form id='qLP9g'><ins id='qLP9g'></ins><ul id='qLP9g'></ul><sub id='qLP9g'></sub></form><legend id='qLP9g'></legend><bdo id='qLP9g'><pre id='qLP9g'><center id='qLP9g'></center></pre></bdo></b><th id='qLP9g'></th></span></q></dt></tr></i><div id='qLP9g'><tfoot id='qLP9g'></tfoot><dl id='qLP9g'><fieldset id='qLP9g'></fieldset></dl></div>