Jonah Elbaz
Jonah Elbaz

Reputation: 325

Firebase cloud functions not executing

Im trying to create some firebase cloud functions and it doesnt seem to be going through. Im a little confused because based on what I read this should work.

Heres my code thats not writing or executing:

   //Custom master notification.
 exports.TrackMasterNotification = functions.database.ref('/'+DatabaseNode+'/GeneralMessage/Master')
    .onUpdate(event => {
        console.log("Processed new CUSTOM notification");
        //news has been created
        InitializeNotificationProcess();
        IdAndNotification.forEach(user => {
                //Should really find out which to send
               SendIOSNotification(user.NotificationId, event.data.val(), 'ping.aiff', 1, 3 );
               SendAndroidNotification(user.NotificationId, event.data.val(),"");
        });

    });

Firebase looks like this:

-Firebase project
 -Development
   - General Message
      - Master: "value"

Edit

const DatabaseNode = "Development";

Ive changed the ref to

ref('/{DatabaseNode}/GeneralMessage/Master')

Upvotes: 0

Views: 1148

Answers (1)

JamWils
JamWils

Reputation: 785

The syntax for the ref path looks wrong. It should be:

/{databaseNode}/GeneralMessage/Master

Also, confirm that it fires when you update an element within that branch of the database since you are using onUpdate.

You should then be able to grab the databaseNode value by using:

const node = event.params.databaseNode;

Upvotes: 1

Related Questions