Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS chat APNS, sockets or time interval [closed]

Tags:

I'm making a chat app for iPhone, but im not sure how conversation messages should come instantly.

I have read tons of Google results on this topic. Also the once on:
- http://www.raywenderlich.com/3932/how-to-create-a-socket-based-iphone-app-and-server
- http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12

APNS approach:
An invisible notification will be pushed to the iPhone indicating that a new message is ready to be read. So the app will make a request for unread messages. So instead of manually polling new messages, I will let APNS help with that. But I'm not sure?

Sockets approach:
Making a socket connection that is open to share data. When new messages is found in db, it will automatic send the data to the app. But what about IP range, firewall, power consumption, other things? again I'm not sure :(

Polling approach:
Make a time interval where I poll request, power consumption is my enemy here.

My question:
- Which approach is best?
- Other suggestions?
- I really need some cons and pros from people with experience on this topic.

Examples is always good.
Thanks

like image 960
Neru-J Avatar asked Jun 30 '12 05:06

Neru-J


People also ask

How fast is APNs?

While in most cases you should expect a delivery in seconds, apparently it can be up to 30 minutes, just due to networking issues such as mobile network drop-outs and other factors.

How does Apple APNs work?

Apple Push Notification service (APNs) propagates push notifications to devices having applications registered to receive those notifications. Each device establishes an accredited and encrypted IP connection with the service and receives notifications over this persistent connection.

What protocol does APNs use?

0, HTTP/2 is the default protocol for connections to APNs. This means that all mobile device management (MDM) communication, such as remote commands, configuration profiles, applications, and push notifications, is handled by the HTTP/2 protocol.

What is APNs Apptds com?

Apple Push Notifications service (APNs) is a cloud-based service that enables third-party apps to establish a connection with a device and send push notifications from a remote server to users within a secure connection.


1 Answers

I think your main concern is how to receive new messages while your application is in the background. Because it's not like I'm going to have a messenger app all day open when I can get notifications with apps like WhatsApp.

Better than TCPIP sockets you could use websockets. Since it is HTTP there are no firewall problems, BUT that requires a permanent connection with application on the foreground which drains the battery.

And because only music, location, or voice ip, is allowed to run on the background, you can't poll unless the application is open. Note that if you register for those background tasks and do something else Apple will notice and reject your app.

Therefore, use APNS. That's what WhatsApp does.

like image 191
Jano Avatar answered Nov 11 '22 15:11

Jano