问题
Based off this is it safe to say that building a real-time news feed type application is better done using polling than with sockets? I'm planning on building a news feed type app for mobile devices and was planning on doing it with sockets but I'm starting to think that it may be better to build a RESTful app instead and just do short-interval polling on the client to get new updates. How have others out there implemented "real-time" mobile apps?
回答1:
In Android, GCM is your best bet for any real-time notifications. It couldn't be simpler or faster to get the real time notifs, if you have a server than can push the notifs.
On iOS, your better off writing a polling mechanism. The best example I can think of is the new Facebook app for iOS. It seems to poll every 30s or so to check for new data. If there is new data, and the user clicks the new stories bar, it will get the new data and display it.
A simple request and timer would work, but there is also a technique called Long Polling that works well in these situations. This will limit the drain on the battery.
So in short, because of Apples restrictions on Push-Notifications, you will have to work around it. However, in general, push notifs are the way to go, all things considered.
来源:https://stackoverflow.com/questions/13371405/ios-android-realtime-news-feed-implementation