1
votes

I have Firestore database. Colletions simple:

"tasks/{taskId}": {
"ownerUid": "task owner Firebase Uid",
"whoDidUids": ["user_1_FirebaseUid","user_2_FirebaseUid"]
}

"users/{userUid}": {"fcm_token": "firestore cloud messaging token"}

Want just to write simple Cloud Function which will be triggered on:

exports.taskDoneNotification = functions.firestore
    .document('tasks/{taskId}')
    .onUpdate((event) => {

       //when another user did task it means 
       //userUid will be added to task.whoDidUids array
       //I want to get task owner fcmToken and send him
       // simple notification like "your task done by someone!"
    });

I'am new to js syntax, writing on Kotlin for Android.
Please provide me some examples how to do this?

1

1 Answers

0
votes

I was trying to do something similar.

Unfortunately the "auth" object where you would get the UserId from is no yet implemented in Firestore Database Triggers. :(

See here:

Question 46912161