Any iPhone SDK API available to promote 3G/GPRS over WiFi in an iPhone application - iphone

I have a requirement to promote 3G/GPRS over WiFi connectivity in the iPhone application I am developing. Please let me know if this is possible and if yes, how?
The problem is when I have a WiFi network which is available and connected but not logged in using Captive Portal, I cannot use that WiFi network to perform the tasks which require internet connection. What i have noticed is Reachability API detects the available WiFi but I cannot use it as I am not logged in and so I am not connected to internet using this WiFi hotspot until I login. So I want to use 3G/GPRS to perform the tasks requiring internet connectivity.
iPhone's default behavior is it uses WiFi when its available and if not then only 3G/GPRS.
So please let me know if both 3G/GPRS and WiFi are available but I am connected to internet not using WiFi but 3G/GPRS how to use 3G/GRPS to perform the tasks requiring internet connectivity.
Regards,

Third-party applications don't get control of where their data comes from. About all you're going to be able to do is ask your users to turn wifi off while your application does its thing. If you need to get back onto wifi after doing the initial data transfer, you could make some clever use of the iOS 4 multitasking and local-notification APIs: when your application enters the background, it could start a background-task handler (using -beginBackgroundTaskWithExpirationHandler: in your app delegate's -applicationDidEnterBackground:) to wait for the wifi connection to become unavailable, do its thing with the cell network, then create a UILocalNotification to tell the user it's okay to turn wifi back on again. That way, the user could get the benefits of whatever your app does and still keep the connection they started out on.

If you are creating an app which needs to access certain network resource(s) to function, then you should just ping, or try to connect to those resources directly instead of just depending on reachability for the decision. If you can't ping your server, then have the app do the same thing it would if reachability reported zero connectivity (even though it may not be).

For security reasons, Apple doesn't allow developer to do such settings pro grammatically, despite you GPRS network connection to achieve some purposes.

Related

How to detect all available Wifi networks and connect to one of them in an iOS app

In my iOS app, I want to detect all available wifi networks and then choose one network form the list and connect to it. The goal is to not open the Settings built in app to connect to a wifi, but to do it all in my app.
First, is this possible? If possible, please point me to what framework(s) and methods to use.
I have looked at the Reachability example, but that doesn't work for me because, I think, all it does is monitor the network state of the device.
I also looked at the Captive Network Support framework, and used the CNCopySupportedInterfaces function:
CFArrayRef allWifiNetworks = CNCopySupportedInterfaces();
NSLog(#"%#", allWifiNetworks);
but all I am seeing is the current wifi network that the device is connected to.
Thanks
I'm pretty sure you can't do this, at least not if you want to be able to publish on the App Store.

Communication between iOS app in one Wi-Fi network w/o server

I need to communicate my app with 2 devices. A restriction is that I can't use a server but all iOS devices will be in one Wi-Fi network. What options do I have? How I can send a message to another copy of my app running on another device?
I dont know whether its a correct approach or not but as you cannot use server,so the approach i can think of is we can create a socket connection using TCP/IP or UDP(based on reliability) for data exchange.
I dont think you can communicate between 2 devices running the same application without having some kind of server application in-between.
Even if you could find the other device over the WIFI I dont think you can tell if the other device is running the app or not.
I think you may be referring to MultipeerConnectivity
The Multipeer Connectivity framework provides support for discovering
services provided by nearby iOS devices using infrastructure Wi-Fi
networks, peer-to-peer Wi-Fi, and Bluetooth personal area networks and
subsequently communicating with those services by sending
message-based data, streaming data, and resources (such as files).
Source: https://developer.apple.com/library/ios/documentation/MultipeerConnectivity/Reference/MultipeerConnectivityFramework/
Apple Sample:
https://developer.apple.com/library/ios/samplecode/MultipeerGroupChat/Introduction/Intro.html

use 3g for internet when connected to adhoc wifi (using private API's)

First and foremost,
I am looking for a resource to use Private API's.
this is an enterprise application and will never go to the app store
I need to take as much configuration out of the users hands as possible.
That being said, I have a device that an ipad will be connected to and communicate with via an adhoc wifi network supplied by the device. the ipad connects to this device and sends raw data to it via socket connections. I also need to connect to the internet for data syncing.
80% of the time, the ipad will be connected to this adhoc wifi device. Management software on the ipad does not allow the user to adjust wifi settings so I am trying to make sure I am connected to my device without limiting my server syncing. I know I can determine the connection using apples Reachability class, this is not what i am looking for. I need to use BOTH 3g AND wifi.
Is there a way to enforce this in code? Or is there a resource for the private API's that I can look at to find a way?
This will be in iOS 5 and the most preferable method would be to just route my http requests via some private api method to use 3G and let the socket requests use wifi to the adhoc device.
code samples would be awesome, links / class names to research would be very much appreciated.
and once again this is not going into the app store, it is an enterprise app
the resolution i found was to assign an ip in the privately assigned ip range the ipad uses (169.254.x.x) to the adhoc device then let the ipad determine an ip. Then see if i can open a socket connection to the device (to determine if its available) and then issue a print.
Going this route, i am still able to use 3g data as well as communicate with the device via wifi.

How to change connection from 3G to wi-fi programmatically using iPhone SDK?

Lets consider that I am connected to internet through 3G in my App. When a wi-fi hot spot seems to be appearing, can I programmatically switch to the wi-fi. Is this vice-versa condition possible?
iOS does this automatically by itself!
If no known WiFi network is found, it uses cellular data. If it finds a known WiFi-network, it connects to and uses that network instead.
If any WiFi-network is found, and your application requests access to the internet, iOS (usually) automatically presents an alertView and lets the user log in to a WiFi-network. If the user does not log into a WiFi-network, it stays on the 3G-network. When iOS 7 comes, iOS may connect to Hotspot 2.0 networks automatically as well.
Apple keeps individual apps on a tight leash, and so they do not let apps control things like this.

Forcing a WWAN connection on iPhone, even when Wi-Fi is available

I need to make a network connection over WWAN (i.e. the mobile network) on an iPhone, even when the device is connected to a Wi-Fi network, however I can't find a way to do this.
I've tried going down to the socket level and iterating through the available interfaces, however when connected to Wi-Fi, the WWAN interface (pdp_ip0) disappears.
The solution needs to be App Store safe.
Enumerate the network interfaces, you will see that when you're connected on both wifi and 3g, there are 2 with different local ip addresses. You might be able to use one vs the other by forcing a bind of your socket on the right interface before sending the data. The kernel which tries to find the best interface to route your packet should be happy with your choice.
Disclaimer: I have not tried this, this is just a suggestion.
Perhaps you can use the Reachability code to determine if Wi-Fi is enabled, firing a UIAlertView to warn the users to quit the app, open the Settings app and switch off wireless manually. Not ideal, definitely.
There is no supported way to to do this. You need to tell the user to turn off the WiFi connection since "It's a non-negotiable operational requirement for the service the app needs to connect to."
In this scenario, the user is not likely to kill you with bad reviews if you are clear about why they have to disable WiFi.
-t