I couldn't create a pagination technic like viewDidLoad: loadPosts() - scrollViewDidScroll: loadMore() for our feeds using Firebase IOS SDK in best logic way. It's easy to me .limit() query on Parse mBaaaS. But I didn't do it with Firebase, there is big problem like UIRefreshControl() comes crash, not loading while scrolling etc.
And then I find that real time updates nice thing for my feeds page, but when I add new post using Firebase Dashboard (I did it for testing like another user adding new post on "posts" root node) tableView scrollUp a little bit by itself. This is bad, if I read something on feed page why app takes me to different place from before.
Is there any way to prevent this scrollUp by Firebase observeEventType(.Value..?
Here'is my viewDidLoad: loadPosts() func:
let query = DataService.ds.REF_POSTS.queryOrderedByChild("timestamp")
query.observeEventType(.Value, withBlock: { snapshot in
if let snapshots = snapshot.children.allObjects as? [FDataSnapshot] {
self.posts = []
for snap in snapshots {
if let postDict = snap.value as? Dictionary<String, AnyObject> {
let post = Post(postKey: snap.key, dictionary: postDict)
self.posts.append(post)
}
}
self.posts = self.posts.reverse()
self.tableView.reloadData()
self.loadingIndicator.stopAnimating()
}
})