I'm trying to translate this other stackoverflow answer which was using the javascript sdk into a swift/obj-c ios solution.
Firebase chat - removing old messages
Here is my code:
messagesRef?.observeEventType(FEventType.ChildAdded, withBlock: { (snapshot:FDataSnapshot!) -> Void in
if (snapshot != nil)
{
msg = snapshot.value["avatar"] as? Dictionary<String,AnyObject>
}
})
So a few questions:
it seems to fire the childadded event for all past messages, not just new events - is that the way it's supposed to work? Is there a way to limit it to just new messages/children and not already existing messages?
How do I add a limit to the reference, like in the js example?
How do I translate this piece of js code into swift?
sample:
messagesRef.endAt(timestamp).on("child_added", function(snap) {
snap.ref().remove();
});