This is the index.js code
const admin = require('firebase-admin');
const functions = require('firebase-functions');
admin.initializeApp();
exports.notifFunc = functions.database.ref("/collegeData/{collegeId}/notices").onCreate((snapshot, context) => {
console.log(snapshot.val());
return admin.messaging().sendToTopic('notices', {notification: {title: "Title", body: "Does this
work?", clickAction: "FLUTTER_NOTIFICATION_CLICK"}});
});
It deploys without any error with the following output.
=== Deploying to '*************'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
functions@ lint C:\Users\kenre\Documents\GitHub\Android Project\************\functions
eslint .
+ functions: Finished running predeploy script.
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
+ functions: required API cloudfunctions.googleapis.com is enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (37.51 KB) for uploading
+ functions: functions folder uploaded successfully
i functions: updating Node.js 8 (Deprecated) function notifFunc(us-central1)...
+ functions[notifFunc(us-central1)]: Successful update operation.
! functions: Warning: Node.js 8 functions are deprecated and will stop running on 2021-03-15. Please upgrade to Node.js 10 or greater by adding an entry like this to your package.json:
{
"engines": {
"node": "12"
}
}
The Firebase CLI will stop deploying Node.js 8 functions in new versions beginning 2020-12-15, and deploys from all CLI versions will halt on 2021-02-15. For additional information, see: https://firebase.google.com/support/faq#functions-runtime
+ Deploy complete!
Project Console: https://console.firebase.google.com/project/*************/overview
My app successfully creates/posts a new key-value pair entry in the specified path ("collegeData/{collegeId}/notices") using the Rest API for Firebase Realtime Database. But the log never appears (waited 4 hours before writing this) and the notification is not sent either. Is there any reason for this? I realise it asks me to upgrade to node version 12 but I am refraining to do so to avoid using a credit card.