hansemannn / titanium-firebase-database

Use the Firebase Realtime Database SDK in Axway Titanium 🚀

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could you please provide an example for this

RavindraChherke opened this issue · comments

Hi,

Thanks for the module. I am trying to integrate firebase database in my project. I am able to authorize on firebase then I can add a child and it's value in database. But I am not receiving callbacks from observableEvents. Could you please check the code below and tell what I am doing wrong.

       var FirebaseDatabase = require('firebase.database');
       var firebaseDatabaseReference = FirebaseDatabase.getReference();
       var channel = firebaseDatabaseReference.child({
		identifier : "channel",
		observableEvents:  [FirebaseDatabase.DATA_EVENT_TYPE_VALUE,FirebaseDatabase.DATA_EVENT_TYPE_ADD,FirebaseDatabase.DATA_EVENT_TYPE_CHANGE]
	});

       channel.addEventListener('value', function(e) {
		Ti.API.info("Value: " + JSON.stringify(e));
	});
	
	channel.addEventListener('add', function(e) {
		Ti.API.info("Add: " + JSON.stringify(e));
	});
	
	channel.addEventListener('change', function(e) {
		Ti.API.info("Change: " + JSON.stringify(e));
	});

	channel.setValue(["MyTestChannel", function(e) {
		Ti.API.info("This is callback " + JSON.stringify(e));
	}]);


@RavindraChherke Since you made a PR recently, you probably used the module by now? Can you add an example for others?

@hansemannn My code is all here and there. I'll create a simple example for this.

@hansemannn,
You have changed the function name getFirebaseServerTimestamp to firebaseServerTimestamp. This also needs to be updated in documentation and example file.

Using the objc bridge generates both the property and the getter with the change I did, so it should be fine. I will update the binary once I am home again. Thank you for your contribution!