iphone - Programmatically set (System-wide) proxy settings? - iphone

I am new to iPhone development, so I'm sorry if this is a stupid question. I am developing an application whose purpose will be to route all iPhone activity through my company's proxy.
Is there a way to programmatically set system-wide proxy settings in the iPhone (which will also take effect on the 3G connection)?
I know there is a way to manually set proxy settings for each wifi connection. Detecting new networks and setting the proxy on them would be acceptable. However, I need to also be able to set the proxy on the 3G connection.
Also, bonus: Is there a way to programmatically change the "Restrictions" settings?
If anyone has any tips or can point me in the right direction, I would appreciate it. Thanks.
EDIT: Please understand that this is for a legitimate purpose. Apple has to approve app store additions, so it's not like I'm trying to spread a virus. Please, constructive answers only.

If you're configuring iPhones in a commercial environment, you should look at the Enterprise Deployment Guide. Specifically, you should look at using the iPhone Configuration Utility to create a *.mobileconfig configuration file that can be distributed to all the phones in your network. The *.mobileconfig plist supports changing the following proxy configuration settings on the phone:
PropNetProxiesHTTPEnable (Integer, 1 = Proxy enabled)
PropNetProxiesHTTPProxy (String, Proxy server address)
PropNetProxiesHTTPPort (Integer, Proxy port number)
HTTPProxyUsername (String, optional username)
HTTPProxyPassword (String, optional password)
PropNetProxiesProxyAutoConfigEnable (Integer, 1 = Auto proxy enabled)
PropNetProxiesProxyAutoConfigURLString (String, URL that points to a PAC file where the configuration information is stored)
The iPhone Configuration Utility does not currently support adding or editing those settings, so you may need to get your hands dirty with the Property List Editor application. Also, it looks like the latest version of the Enterprise Deployment Guide does not include the settings I've included above, but you should be able to find it in the previous version of the document.

Pretty sure this is outside the Apple provided SDK sandbox. Probably possible with a jailbreak though.

Related

iOS MDM - Making Managed settings permanent

As per the "Mobile Device Management Protocol" API document from Apple, I am trying to restrict access to Data Roaming on iOS devices connected to my MDM server.
I can toggle the Data Roaming setting by sending the appropriate Settings request, however the user can then toggle Data Roaming straight back on.
This is addressed in Apple's documentation with the following paragraph :
In iOS 5 or later, this command allows the server to set settings on the device. These settings take effect on a one-time basis. The user may still be able to change the settings at a later time. This command requires the Apply Settings right.
The "might" suggests to me that there should be a way to restrict this, but I can not find a complete list of Global Restrictions that might solve this problem.
Is there a way to remove access to either the "Data Roaming" settings option, or even disable access to the whole "Settings->General->Cellular" sub menu ?
I don't think it's possible.
I checked the document with configuration profiles:
http://developer.apple.com/library/ios/featuredarticles/iPhoneConfigurationProfileRef/iPhoneConfigurationProfileRef.pdf
Also, I checked iPhone configuration utility.
None of them has Data Roaming restriction.
So, the only thing available is that MDM Settings which you are using already.

How to add a wifi network to the list of known ones in iOS?

I am working on an app that needs to add a wifi network (i.e., SSID and password) to the list of known ones of the mobile phone, so that it connects to that network automatically even when seeing it for the first time.
I already did this on Android, and now I will start working on the iPhone version.
Question: On the iPhone, is it possible to have my app (when it runs for the first time) add a wifi network to the list of known ones of the device, and if so, any hints regarding how to do it?
Thanks a lot.
Unfortunately this is not possible on iOS.
Apple doesn't provide any public APIs to add network SSIDs or passwords.
The most you can do is to enable your app to manage the user's authentication for a public network, (as is done for things like Boingo and The Cloud). In this case, when the user joins a network, instead of a webpage opening to authenticate, your app can launch and provide the authentication - but that is as far as you can go.
We asked for clarification on this point to Apple in the dev forums and were told that it is definitely not possible. (I will try to dig out the link to that post for you when I get more time. Else, search your query on the dev forums and it might show up).
so it would seem that with iOS 6, there may be a way to do this. Boingo appear to allow a user to turn on "Auto Login" and it will login/authenticate against the access point without the user interacting/authenticating manually (I haven't tried it myself though). Is there new API calls in iOS 6 that now allows this? See this article.

WiFi possibilities on iOS

Is it possible on iPhone to create a data connection by specifying the SSID of the network?
Is it possible from application to check the signal/availability of the network with specified SSID?
Regards,
STeN
What you're trying to do is sadly not possible without the usage of private (undocumented) API-s.
Hopefully Apple will provide this kind of functionality (with users permition) though i don't think this is bound to happen soon.
If you want to research this topic further the first place to check would be iphone-wireless - the home of Stumbler which shows a nice usage of MobileApple80211.

Find if 3G is enabled in iphone settings

is it possible to find whether 3G or Edge is enabled in the phone setting through applications?
Its not possible to read the private Settings data (since apps generally can't access data that is not thier own), so I don't think this is possible. However, you can use the [Reachability]
(http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html) code from Apple. Also, you can try going through NSUserDefaults.

iPhone handling dynamic URLs

My iPhone app consumes a Java web service in order to get data. At my company we have 3 environments - development, testing, production. Each environment's URL, that points to the web service, is different. Thus, each time we promote the project to the next environment I must change the hard-coded URL in the iPhone code to match that of the targeted environment. Has anyone devised a strategy to handle this either on the iPhone itself or in the service layer?
Try storing the variable part of the URL in your app's info.plist file. You can change that w/o rebuilding.
If more config changes are needed, VCS branching may be what you need.
You might consider the following approach:
When you start up your app, or rather when you have established that a network connection is possible, you send your device id to the server.
The server checks your device id against a list and tells your app whether the user talking to the server is allowed to see development and testing content.
If your device is allowed to, you provide an interface for the user to change whether they want to see development, testing or production content. Store that in NSUserDefaults
Depending on user choice, the corresponding url is used to talk to your server. To be sure, you can include your device id check here, too.
This approach has the benefit that you can allow clients to see testing content... without ever having to update or change their app. And you can revoke that permission anytime.