Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use only WiFi connection (not cellular network) in app?

Tags:

xcode

ios

My app has been rejected in the Apple app-store.

To fix this, it must use only WiFi and not cellular network connection when the user is using the application. The application uses UIWebView -- how can we go about implementing this restriction?

Any help will be appreciated, Thanks!

like image 332
Laura Marte Avatar asked Nov 29 '11 20:11

Laura Marte


People also ask

How do I make my apps only use Wi-Fi?

For instance, to limit mobile data use for an app, tap the cellular data icon to its extreme right. Otherwise, tap the Wi-Fi icon next to it to restrict the app from running on a Wi-Fi network. Select both icons to stop an app from using data at all.

How do I use Wi-Fi instead of cellular data?

The same setting on Android phones can be found in the Connections area of the Settings app. Go to the WiFi settings, tap the three dots in the corner to find the advanced settings menu, and then turn off the toggle that says "Switch to mobile data."

How do I make my iPhone apps only use Wi-Fi?

Set cellular data use for apps and servicesGo to Settings > Cellular, then turn Cellular Data on or off for any app (such as Maps) or service (such as Wi-Fi Assist) that can use cellular data. If a setting is off, iPhone uses only Wi-Fi for that service. Note: Wi-Fi Assist is on by default.


1 Answers

Take a look at the Reachability example from Apple.

With that, you can query the device about the current network status, so you can know if Wifi is available, or if a connection will need cellular network. In the last case, you may display an alert, and prevent your UIWebView to load the data.

EDIT

If you have imported the reachability class into your project, and added the required framework(s), here's an example. This will test for an available WiFi connection:

Reachability * reach;
NetworkStatus  status;

reachability = [ Reachability reachabilityForLocalWiFi ];
status       = [ reach currentReachabilityStatus ];

if( status == ReachableViaWiFi )
{
    /* Hurray, you've got a WiFi connection! */
}
else
{
    /* No WiFi connection - Alert the user! */
}
like image 76
Macmade Avatar answered Nov 15 '22 09:11

Macmade