Dani Kemper
Dani Kemper

Reputation: 343

Firebase Functions deploy error : Error occurred while parsing your function triggers

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

exports.sendPushNotification = functions.database.ref('/Rollerbanken/{id}').onWrite((event => {
    const payload = {
    notification: {
    title: 'New message arrived',
    body: 'come check it',
    badge: '1',
    sound: 'default',
    }
};
    return admin.database().ref('fcmToken').once('value').then(allToken => {
    if(allToken.var ()) {
    const token = Object.keys(allToken.val());
    return admin.messaging().sendToDevice(token, payload).then(responds => {
            });
        };
    });
});

Error: Error occurred while parsing your function triggers.

/private/var/folders/s3/gnf3bs6s0_n5jx27n2zj3xwr0000gn/T/fbfn_75373XQetWUjR4EdN/index.js:21 }); ^

SyntaxError: missing ) after argument list at createScript (vm.js:74:10) at Object.runInThisContext (vm.js:116:10) at Module._compile (module.js:588:28) at Object.Module._extensions..js (module.js:635:10) at Module.load (module.js:545:32) at tryModuleLoad (module.js:508:12) at Function.Module._load (module.js:500:3) at Module.require (module.js:568:17) at require (internal/module.js:11:18) at /usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:18:11

Upvotes: 0

Views: 1715

Answers (1)

Malik Ahsan
Malik Ahsan

Reputation: 989

As mentioned you ref is not valid. The database reference is case sensitive and should be like this

functions.database.ref('/Rollerbanken/{id}').onWrite(

You have the reference to database with D in uppercase. It should be lower case.

Go through this for complete implementatio

https://firebase.google.com/docs/functions/database-events Hope that helps.

Upvotes: 0

Related Questions