当前位置: 首页 > 知识库问答 >
问题:

Firebase FCM参考错误的云函数

孟祯
2023-03-14

错误

引用错误:函数未在对象中定义。(C:\用户\CROWDE~1\AppData\本地\Temp\fbfn_9612Si4u8URDRCrr\index.js: 5:21)在模块。_compile(module.js:570: 32)在对象。模块。_extensions... js(module.js:579: 10)在Module.load(module.js:487: 32)在tryModuleLoad(module.js:446: 12)在功能。模块。_load(module.js:438: 3)在Module.require(module.js:497: 17)在需要(内部/module.js:20: 19)在C:\用户\Crowderia\AppData\漫游\npm\node_modules\fire base-tools\lib\triggerParser.js:18: 11在对象。(C:\用户\Crowderia\AppData\漫游\npm\node_modules\fire base-tools\lib\triggerParser.js:32: 3)

指数js文件如下

'use strict'
const funnctions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendNotification = functions.database.ref('/Notifications/{user_id}/{notification_id}').onWrite(event => {
  const user_id = event.params.user_id;
  const notification_id = event.params.notification_id;
  cosole.log('User id is : ', user_id);
  if (!event.data.val()) {
    return console.log('A Notification has been deleted from the database : ', notification_id);
  }
  const deviceToken = admin.database().ref(`/Users/${user_id}/device_token`).once('value');
  return deviceToken.then(result => {
    const token_id = result.val();
    const payload = {
      notification: {
        title: "Friend Request",
        body: "You've received a new Friend Request",
        icon: "default",

      }
    };
    return admin.messaging().sendToDevice(token_id, payload).then(response => {
      console.log('this is the notification feature');
    });
  });
});

共有2个答案

蒋高超
2023-03-14

cosole。日志('User id is:',User\u id) 将其更改为控制台。日志('User id is:',User\u id) 和函数的功能。

唐利
2023-03-14

你第一行有个错字

const funnctions=要求(“firebase-functions”);

函数,而不是funnctions:)所以这一行

功能。数据库ref('/通知/{用户id…

会有用的

 类似资料:
  • 我在cloud firestore中有2个集合,希望通过我的产品“userBids”的一个字段使用这两个集合,我正在使用文档参考: Ürünler(产品) 问题我想从我的产品模型中的“userBids”字段联系我的用户,但下面出现了错误; 类“DocumentReference”没有实例方法“[]”。 接收方:“DocumentReference”的实例 试着打电话:) 那么,我如何才能在Flat

  • http状态码 状态码解释 错误码 错误码解释 400 Bad Request - - - - 400001 Invalid parameters - - 400002 Missing parameters 401 Unauthorized - - - - 401001 Unauthorized user 403 Forbidden - - - - 403001 Not allowed to ac

  • 当我今天打开我的eclipse时,当我创建一个新的android项目时。appcompatv7会根据新的SDK自动导入。但是appcompatv7显示了一些错误。当我展开appcompatv7时,res-->values-large->theme_base.xml和res-->values-large-v14-->theme_base.xml中出现错误。这些xml文件中的错误显示“找不到与以下名称

  • 我已经使用firebase云函数一段时间了,今天在代码中修复了一个小错误,在尝试部署时出现了以下错误。我取消了该更改,并尝试使用上次提交的稳定更改再次部署,但仍然是相同的错误。有什么解决办法吗?PS:这是一个typescript项目,我用tsc编译它。

  • 以下是标准Perl支持的所有重要功能的列表。 abs - 绝对值函数 accept - 接受传入的套接字连接 alarm - 安排SIGALRM atan2 - 在-PI到PI的范围内的Y/X的反正切值 bind - 将地址bind到套接字 binmode - 为I/O准备二进制文件 bless - 创造一个对象 caller - 获取当前子例程调用的上下文 chdir - 更改当前的工作目录 c

  • Section Contents 字母顺序索引 字符串内建函数 数字内建函数 日期内建函数 布尔值内建函数 序列内建函数 哈希表内建函数 结点(对于XML)内建函数 循环变量内建函数 独立类型内建函数 很少使用的和专家级的内建函数