Im using restkit and push notifications and I have also built the interface, so here is my question I wanna know your opinion on how to build the structure of a chat app with restkit.
- Should I update the incoming messages every 5 min ? OR
- Should I update when I receive a push notification ? OR
AND - should I use the restkit queue to do this?
- Should I use restkit core data ?
So, I guess my question is the best way t ask the server new messages.. so what is your recommendation???? mmmm… is there any example or framework ??
THANKS!!!
If you’re building any sort of chat application, your users will expect that their messages are received immediately. I will assume that your server dispatches a push notification as soon as it receives a message. You should poll the server for new messages when the following events occur:
If your server reliably sends push notifications when an event occurs, you shouldn’t need to manually poll.
You shouldn’t need to directly interact with the RestKit Request Queue for something as trivial as this.
RKClientcan safely manage it for you.Remember that the user will expect the app to handle network reachability issues well. The request queue will do reachability tests for you and appropriately queue requests until the network is available, however you may need to listen for notifications and provide an appropriate response. To do so, you should register for
RKReachabilityStateChangedNotificationNSNotificationCenternotifications posted by the RestKit framework. You may also need to save unsent messages locally and retry them later, especially if the application is suspended/terminated.Remember to keep track of some sort of unique identifier you can use to tell the server what message you most recently acquired. The server should then send you an array containing every message after that point.
Finally, Core Data is a great way to store data that must persist between launches. With RestKit (and inherently with core data) your data is conveniently available as a collection of objects, and you can perform powerful queries against this data.