I am following a tutorial to deploy a function to firebase. when I deploy I get an unknown error whereas the tutor doesn't. I have looked through this line for line and it's exact. Can anyone else shed any light on this?
// The Cloud Functions for Firebase SDK to create Cloud Functions and setup triggers.
const functions = require('firebase-functions');
// The Firebase Admin SDK to access the Firebase Realtime Database.
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const ref = admin.database().ref
exports.sendPushNotification = functions.database.ref('/posts/{postId}/question').onWrite(event => {
const payload = {
notification: {
title: 'A Question has been posted',
body: 'Check out the question posted ',
badge: '1',
sound: 'default',
}
};
return admin.database().ref('fcmToken').once('value').then(allToken => {
if (allToken.val()) {
const token = Object.keys(allToken.val());
return admin.messaging().sendToDevice(token, payload).then(response => {
});
};
});
});