Extended README by adding "how to integrate with a network service" instructions #114
Extended README by adding "how to integrate with a network service" instructions #114dodikk wants to merge 10 commits into
Conversation
| // | ||
| _ = super.sendText($0.text, isIncomingMessage: $0.isIncoming) | ||
| } | ||
| } |
There was a problem hiding this comment.
Sorry it took me a while to get around to explaining this. It's the perfect use case for head async prefetching.
To use this, you need to set doesBatchFetch: Bool = true on NMessenger. NMessengerViewController should implement the NMessengerDelegate. You will need to add the optionalfunc batchFetchContent() to the ViewController. This function will be called when you start to scroll up in the chat history. Ideally, the client should fetch history rather than the server pushing it to the client. The following code describes this functionality:
func batchFetchContent() { //called when you begin to scroll up and NMessenger decides that messages could be prefetched
getMessages { (messages) -> Void in //call your server to get messages
endBatchFetchWithMessages(messages: messages) //adds messages to the beginning of the NMessenger
}
}Calling endBatchFetchWithMessagesclears the lock on the prefetch mechanism so that it can be called again when you continue to scroll up.
There was a problem hiding this comment.
@atainter , i am sorry but i am still unsure how to extend my PR properly. I would be grateful if you elaborated on adding the missing parts and posted the result to a readme (or a wiki page or some other documentation piece for this library).
There was a problem hiding this comment.
Some topics to cover:
- Add some details of the prefetching usage to the readme.
- How to open the chat with some history pre-populated. Meaning, what to do after an async service call from
viewWillAppearNotifies the completion. - How to handle the "some past offline messages have been pushed by the server" situation you've described in your comment.
There was a problem hiding this comment.
As far as How to handle the "some past offline messages have been pushed by the server" situation you've described in your comment. goes, NMessenger is not really setup for that. The client is meant to query for past offline message. Currently, you cannot add messages out of order because of the way referencing was built. I would build your server to send history in order so that you can use the batchFetchContent() callback.
I created a docs-wip branch. Can you resubmit the PR to merge with that branch? I'll help edit the docs to further explain 1 and 2.
Done : #116 |
|
A bit more samples/snippets (just in case) documented |
Fixing #95
Topics Covered :
cocoapods badgeadded