Pregunta

If i were to make an instant messenger for iOS, how would i go about checking for new messages?

Would it involve continuous checks to a web service to see if there are any new messages (e.g. every few seconds), or some kind of live feed with the web service to update the app immediately?

¿Fue útil?

Solución

You can use NSStream and CSStream to communicate from within your iOS apps to a TCP server. Keeping an open socket connection with your server will allow the server to send you a notification about the new message instantly. You will need an output stream (NSOutputStream) and an input stream (NSInputStream) so you can manage outgoing and incoming communications easily and in parallel.

Some useful links:

Introduction to Stream Programming Guide for Cocoa

How To Create A Socket Based iPhone App and Server

Tutorial: Building A Simple iOS TCP Socket Based App Client And Server

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top