Data sync with Firebase of a social app


#1

Hi guys, I explain my problem.

I want that the apps syncs automatically with data stored into the db and then I have to put this data into a map as markers.
The data has to be downloaded from the db when I open the app, but it has to be checked also if the app contains into its cache that data (in order to not download the same thing twice). And I need to keep in sync with the db so that the app can download some new data stored into the db from another user that is using the app too…
I tried to explain as well as I could

Firebase has “ChildListener” and “Sync” function, what’s the difference between them?
I have tried the “ChildListener”, it returns each data as a JSON, but then if I try to add a marker for each data that the app receives, it crashes

here is the ChildListeners into the load function of the home page

  var onChildEvent = function(result) {
    console.log("Event type: " + result.type);
    console.log("Key: " + result.key);
    console.log("Value: " + JSON.stringify(result.value));
    mapFunction.addMarker(map,result.value)
  };

  // listen to changes in the /users path
  firebase.addChildEventListener(onChildEvent, "/posts").then(
    function(listenerWrapper) {
      var path = listenerWrapper.path;
      var listeners = listenerWrapper.listeners; 
    });

and here there is the addMarker event

console.log(res);
    
    counter++;
    marker.position=mapsModule.Position.positionFromLatLng(res.lat,res.lng);
    marker.icon=res.fileURL;
    marker.userData={index: counter};
    map.addMarker(marker);
    console.log("marker added "+counter );
}

Let me know if something is not clear


#2

nobody can help me ?


#3

I was thinking of using google place but the plugind doesn’t work… Does someone know how to let it work?


#4

nobody can help me ??


#5

Can you provide the stack trace error message when the app crashes?


#6

I have fixed the crash of app, it was a problem of the map… but know I would like that the data syncs automatically, with the onChildEvent, it just downloads all the data every time from the db…


#7

ok, I haven’t used the data sync function of firebase. I pull my data for the map from the api every time.

Randy


#8

ok I’ve understood… but it is possible to set an Icon of a marker with an image using its URL?


#9

That is on my to do list to figure out. I have not done it yet but it should be possible since you can do that with the web api.