Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIRequiresPersistentWiFi equivalent for cellular connection

OK, so I specified a UIRequiresPersistentWiFi key of my App's plist to YES so the iOS won't stop fetching the data when my app is in the background.

However, when the user uses cellular connection (not wifi) and my app is in the background, the download of the data is stopped after several minutes.

I double checked the docs and it seems there is no equivalent of UIRequiresPersistentWiFi for cellular network that I could set.

Is there any way I can make the connections over cellular network survive while the app is in the background? Any hints?

Cheers!

Updates:

I am making an Internet radio app. Stream is combined with mp3s which I request one after another (can't request them in advance, can't change server side). It works when my app is in the background and uses wifi. However, when using cellular connection the network requests are not performed after some time spent in the background. There is no place for changing the strategy. The app is in the AppStore and it had worked before. I guess they changed something in the new version of the system.

What is more I do not need throttling. My radio app has been already approved and is in the AppStore. The stream is sent with 128kb/s (that is the maximum) so that is not a problem. It looks like system silences my network requests (when on cellular network) after some time in the background. However, this only happens when I try to start the connection in the background.

Description:

  1. App is in the background playing a mp3 streamed over cellular network.
  2. Mp3 ends
  3. I request the URL to another mp3
  4. The request is not performed*.

*works when using WiFi.

like image 275
Rafa de King Avatar asked Jan 13 '12 12:01

Rafa de King


2 Answers

I'm fairly certain there isn't something like this for Cell networks. Here is my reasoning:

  • Cell service costs money. A LOT of money. Per minute. Wifi service does not cost money, in comparison.
  • AT&T does not have very much bandwidth, and charges users extra for extra bandwidth usage.
  • Apple is a company that wants to make the user experience as clean and nice as possible.
  • When costs are exorbitant through no fault of their own, users are angry and their experience is not nice.

If Apple lets you have a constant connection to the web outside of wifi range, the user's cost of service would skyrocket and they wouldn't know why. And if Apple gives programmers this ability, somebody would abuse it. So, I'm sure that Apple won't allow you to do that.

Why do you need a constant internet connection when your app is in the background anyway (unless, I guess, you're making an internet radio app)? Keep in mind that, when in the background, your app can be terminated without warning at any time. You may want to rethink your strategy if you can't find a way to do this. :/

like image 95
Tustin2121 Avatar answered Nov 15 '22 08:11

Tustin2121


I think there is no equivalent of UIRequiresPersistentWiFi, there reasons probably include the ones pointed out by Tusting2121.

But please note that UIRequiresPersistentWiFi is connected with energy saving. The wifi module consumes energy, so normally it is shut down after some time to save some energy unless UIRequiresPersistentWiFi is set. Such enrgy saving, I believe, is not a case in cellular case.

And the fact that your connection disappears after certain minutes in cellular mode may be caused by something completely different that the copy of wifi energy saving mechanism you claim. See for example this article which suggests that you are obliged to throttle your 3G data flow.

like image 22
Krizz Avatar answered Nov 15 '22 08:11

Krizz