hansemannn / titanium-firebase-database

Use the Firebase Realtime Database SDK in Axway Titanium 🚀
Other
7 stars 5 forks source link

Could you please provide an example for this #1

Closed RavindraChherke closed 6 years ago

RavindraChherke commented 6 years ago

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));
    }]);
hansemannn commented 6 years ago

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

RavindraChherke commented 6 years ago

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

RavindraChherke commented 6 years ago

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

hansemannn commented 6 years ago

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!