Reputation: 4601
I am building application for chatting. As it is a chatting app, so the messages got to be real quick. Web services are ready and web service sends message notification and I got to act accordingly on the application. API sends notifications & android version uses GCM to achieve the same. Socket IO is used for developing the server side.
My concerns are :- I can use APNS to get the notifications. BUT is usage of APNS reliable for such an application.
On many sites I have read - APNS is just for sending notifications & not direct messaging & many other factors of it. On many sites/comments I also read that If is fast & reliable, developers have used it successfully in their messaging systems.
Can you please help me know the facts - Is it appropriate for chatting application ? What are the other alternative or better solutions. When more people will be chatting, will that affect the APNS or so..
New API's will be designed based on my needs - so am not stuck to using a single pattern.
Need your guidance to decide to opt the right technology to use. Any help is highly appreciated.
Thanks
Upvotes: 1
Views: 961
Reputation: 1502
APNs are not reliable as doc says. I can suggest to use socket connection for chat purposes. I've implement it in my last application and it works very well. I've used CFNetwork API for persistent connections:
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)kServerIP, kServerPort, &readStream, &writeStream);
self.inputStream = (__bridge NSInputStream *)readStream;
self.outputStream = (__bridge NSOutputStream *)writeStream;
//Add streams to run loop
[self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[self.outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[self.inputStream open];
[self.outputStream open];
//Then handle NSStream delegates for in/out messages
...And also you can use APNs to notify user while in lock screen.
Upvotes: 1