Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push vs polling with web service on iPhone

I'm using the ASIHttpRequest library to ask a web service every minute for updates. The app receives a json string and parses it. It works OK.

But I'd like to make this more efficient.. what would be the best way of getting the server to send to the app info whenever there is an update.. rather than constantly polling the web service?

like image 342
cannyboy Avatar asked Apr 27 '11 14:04

cannyboy


2 Answers

Apple PUSH notification is not a good solution

1) You can only package a limited amount of data to it 2) It may be difficult to figure out if users have the app launched, or exited. If you keep sending PUSH even after users exit the app, they will end up with lots of spam. If you try to send something to the server to indicate that users have closed the app so it should stop sending PUSH, it may not work when the app crashes.

I suggest you use Sockets.

Or just use a scheduled loop to make requests every minute.

.....

But I wonder if you can just send a PUSH without alert body and sound, and just sending a 0 badge. If app it opened, it will be able to feedback to the server to continue sending update. If there is no feedback, stop sending push .

like image 105
honcheng Avatar answered Oct 25 '22 19:10

honcheng


Apple's push notifications may be what you are looking for. However, you'd need to implement something on the website to support them I believe. I haven't used them myself (I haven't gotten that far into my application development), but here is a link to the developer documentation for it: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html

like image 2
Jeremy Dentel Avatar answered Oct 25 '22 18:10

Jeremy Dentel