1
votes

I am trying to set up cloud functions in firebase, and couldn't get it to run for when a user is followed, so tried setting up a simple project for creating a user, and am now trying for any change on the users branch of the database and it is still never triggered. The function shows up in my dashboard, but never triggers.

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

exports.onUserCreateNotification = functions.database.ref('/users/')
    .onWrite((change, context) => {
      //const userUid = context.params.followedUid;
      console.log('We have a new user UID:');
  
    });
1
yep users node is lowercase, I guess the database.ref part at the beginning is somehow wrong, but it is uplaoding the functions to the correct project - Michael
Just tried reinitializing another folder from scratch and uploading again and still nothing in the logs/invocations - Michael
It runs on the test console if I put this and hit test: {"users": "lsdjfksfjskdflajfkdsjkl"}, but not if I create a user outside of the test console, even just hitting add document in the database doesn't trigger it - Michael
Any updates on this? I'm having a very similar issue. - denislexic
unfortunately, don't think I ever figured out the issue @denislexic - Michael

1 Answers

0
votes

Try: exports.onUserCreateNotification = functions.database.ref('/users/{userId}')