iOS app with real-time updates from server: Socket (using streams) or Apple Push Notification service?
I’m trying to make an iOS 5 app that features real-time things coming from the server. It will only use these whilst the app is running.
To make it real-time without polling I have been evaluating two design routes:
Creating a socket from the app to the server, and exchanging information via streams.
- Pros: Relatively simple and would not involve a 3rd party.
- Cons: Battery life drain.
- For an overview of how this might work, check
out this excellent tutorial:
Using standard HTTP to communicate with the server, and with each request from the app let the server know what they are viewing. If something new is available for user, send an Apple Push Notification (with no visible alert) to let app know it can go and download new thing.
- Pros: Not opening up a new TCP connection, so battery life not drained unnecessarily.
- Cons: Feels like a poor hack.
- The official docs on APNs http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html
I think a socket would be the way to go, but before I commit to it I wanted a second opinion, as this is the first time I’ve made anything like this!
- How to generate development MDM/APNS certificate?
- Detect if the app was launched/opened from a push notification
- Sending iOS notification through a php script: 'Unable to set private key file'
- How can I implement Apple Push Notification Service on iOS Application?
- Detect if application: didReceiveRemoteNotification: fetchCompletionHandler: was called by tapping on a notification in Notification Center
- Apple push notifications and Emoji characters
2 Solutions Collect From Internet About “iOS app with real-time updates from server: Socket (using streams) or Apple Push Notification service?”
Does it really need to be “full real time”? From my point of view i would prefer http since it is already well integrated into the iOS SDK. Its easy to understand, maintain and implement and plenty of documentation is on the web. So maybe a http poll every minute or so will be enough (depending on the app and the number of users). Please consider firewalls too! Traffic to unknown ports maybe denied due to firewall policies of provider or local wifi. So if you really need realtime connectivity I guess you have to use sockets.
Sockets would be my choice. I do not know how time critical your application is, but sockets might perform better as APNs if realtime is a must.
- How to upload image with parameters using Alamofire in Swift
- How to change center of gravity in sprite kit game?
- Change Sinch SMS Verification Text
- Why use an extra let statement here?
- when and where to put @class declarations
- Geofence API for iOS 5
- iOS8 CoreData “use of unimplemented initializer”
- Passing an array to sqlite WHERE IN clause via FMDB?
- Parsing Excel Data in Apple Swift
- selecting a random objectAtIndex from NSArray
- MPMoviePlayerController does not work with movie in documents folder
- xcode ios HMAC SHA 256 hashing
- How to tell Smart Invert in iOS 11 not to invert my app colors and detect if it is enabled?
- Tableview not scrolling smooth with static data
- how to determine which tabbar index is my view controller