I have an iphone app receiving network message from server. It is ok when the app is running in frontend.
However, when the app is running in background, the app does not receive network message. After I bring it back to frondend, it starts receiving.
How to make the app can receive network message even it is running in background?
Thanks.
First check this post: iphone - Connecting to server in background
Second, specifically speaking, when you app is in the background and is frozen by the OS, it won't have access to the internet, thus any call back from an async request won't be heard by your app.
Third, a possible strategy:
I'm not an iphone dev but for me, for all background apps, all network messages should be push to apple server and then push to the phone. There is no service like in Android.
You've got two options for network connection while in the background:
Push Notifications. The app is not running, but your server can request to send a notification, which will then be sent to the iPhone, prompting the user to launch your app which can then update itself from your server thru a regular request.
Background network calls. Your app can request to keep a thread alive in the background in order to finish a network activity. You could use this to send a request when your app closes to check in with your server.