'Firebase RTDB trigger not fired from Flutter Firebase SDK triggering event
I am developing an application in Flutter and during development, I encountered this anomaly.
On Firebase Realtime Database I have a simple trigger for testing the functionality, the trigger is this:
/**
* Triggered by a change to a Firebase RTDB reference.
*
* @param {!Object} event Event payload.
* @param {!Object} context Metadata for the event.
*/
exports.helloRTDB = (event, context) => {
const resource = context.resource;
// log out the resource string that triggered the function
console.log('Function triggered by change to: ' + resource);
// now log the full event object
console.log(JSON.stringify(event));
};
(Function name: createGame)
Function to execute: helloRTDB
Trigger type: Firebase Realtime Database (beta)
Event type: create
Database: my-db
Path: /lobby/{userId}
When I run this from Cloud Functions Testing on Google Cloud Platform works well but this does not work when I run the triggering event from Flutter - Firebase Database SDK.
Cloud Functions Testing:
Flutter - Firebase Database SDK:
class FirebaseLobbyRepository {
final lobbyCollection = FirebaseDatabase.instance.reference().child('lobby');
Future<void> test() {
return lobbyCollection.set('test'); // This work but attached trigger not.
}
}
When I call test() method the record is added in the RTDB but the trigger is not fired! Why?
Thanks for the help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|