14

I want to on/off airplane mode in iOS programmatically. After googling, i got some of the following links, and followed them,

Reachability airplane mode (3G) vs. Wifi

Using Private Framework: Importing RadioPreferences.h

Detect if iPhone is in Airplane mode?

All of the above links, tell me to use AppSupport.framework and using RadiosPreferences.h. This is giving me the status about whether airPlane mode is on or off, But it doesn't make me to change the airplane mode.

Then i saw, this link, How to turn on/off airplane mode in IOS 5.1 using private API, that gives me the way for toggling airplane mode but it is using entitlements, which only works for jailbroken devices. Is there any way, to set Airplane mode programatically(can use private APIs but not entitlements).

Community
  • 1
  • 1
Mehul Thakkar
  • 12,440
  • 10
  • 52
  • 81
  • 5
    I think it's highly unlikely you'll be able to change the mode programmatically, since it's a very "un-Apple" way of work to change this mode without user interaction, since a user might wonder why his internet or the ability to get phone calls suddenly stopped working. – Wolfgang Schreurs Dec 09 '13 at 11:32
  • I just want to make app that just put my device in to airplane mode automatically for some time-period, for ex. when i enters office/workplace and it should automatically make airplane mode on, and it will make it off when i leave my office... – Mehul Thakkar Dec 09 '13 at 11:39
  • 1
    I *think* the best you might be able to achieve, is show a notification that guides the user (e.g. by pressing a button) to the Airplane setting and then the user would still have to manually change the setting. Apparently you can use Siri to open the Airplane settings screen: http://forums.imore.com/siri/223832-use-siri-access-system-preferences.html – Wolfgang Schreurs Dec 09 '13 at 11:58
  • yaa, that's the last way, if i dont get the answer of this... – Mehul Thakkar Dec 09 '13 at 12:02
  • 1
    Check This Answers http://stackoverflow.com/questions/793924/activate-airplane-mode-programatically – Ashish Kakkad Feb 14 '14 at 05:11
  • I have already checked that answer, not possible is not an answer of any question, It was also possible for older versions, so there should be something that allows it to toggle airplane mode programmatically(may be it will not allow us to put that app on AppStore) – Mehul Thakkar Feb 17 '14 at 08:49
  • Using entitlements it the only way to give your app permissions to interact with anything outside of the app's sandbox. (iCloud, Passbook, Game Center, etc) There's no way around this otherwise it would be a security hole. Accessing system settings is the same, you need an entitlement. The only difference is that this entitlement is not available to normal apps, hence why a jailbreak is needed. What you're asking for is not possible and there's a very good reason why . – Brandon Schlenker Feb 17 '14 at 23:32

2 Answers2

5

Every single App Store app is sandboxed with entitlements.

What you are trying to achieve is simply not possible if you want to distribute your app in the App Store. Your App simply cannot get enough privileges to achieve anything remotely similar. You cannot set global settings that changes the behaviour of the system. Apple will never allow that.

At the best you can monitor the status of the network connectivity via reachability but this is pretty much it. Using private API = straight app rejection.

Tibidabo
  • 21,461
  • 5
  • 90
  • 86
  • 7
    As i have mentioned that i want to use private API, that obviously means that i dont want to put it on App store, so no point of rejection. – Mehul Thakkar Feb 20 '14 at 09:57
  • I've watched this video which one of the people there say the app is allowed to turn on/off Airplane mode, and he is using IOS : https://www.youtube.com/watch?v=ZcjtEKNP05c . Is this a fake or something? – android developer Feb 07 '15 at 23:41
-4

If you don't care about AppStore submission and if your device is jailbroken (up to iOS 7.0.4 are jailbreakable), then you can follow these steps in exact order to programatically turn on or off Airplane Mode. I am also attaching a sample project to make things easier.

  1. Download (https://iosopendev.googlecode.com/files/iOSOpenDev-1.6-2.pkg) and install. This will install the necessary tools in order to directly install the app in the place where Apple's apps are located. This is needed so that you have a proper access and permission.

  2. Install OpenSSH in your device using Cydia. Then follow this tutorial: (http://www.priyaontech.com/2012/01/ssh-into-your-jailbroken-idevice-without-a-password/) to enable access without password (Using SSH key).

  3. Download the sample project I created from here: (https://www.dropbox.com/s/c0i76vmtfckvsut/ToggleAirplane.zip) This project uses the same entitlements as SpringBoard app (App that controls home screen) of Apple. So you will have access to every setting. You will only need to know how to call it programatically.

  4. In build settings go to "User Defined" section and edit the value for key iOSOpenDevDevice to the IP address of your device.

  5. Now most awesome part. Press Command + Shift + I. This will install and respring your device.

  6. However you may not see the app. To see it, download the Respring app from Cydia. When you launch it, it will respring the device. You should be able to see the app "ToggleAirplane" on your home screen.

Note: You won't be able to delete it from home screen just like you cannot do with Apple's apps. To delete it, you will need to go to Cydia->Packages. Fine the app and uninstall.

  • I dont want to go with Dynamic libraries, i already know this way and already done, but as i have clearly mentioned in my question(last line) that i dont want to go with jailbroken solution, i can use private frameworks – Mehul Thakkar May 02 '14 at 07:20
  • 1
    I know this is an old answer, but I was wondering if you could re-upload the ToggleAirplane sample project. Thanks! – Nahum G Jun 29 '15 at 20:14
  • 1
    Please don't answer questions here without providing the key elements of the answer **in your post**. You have provided a solution, linked to a Dropbox project that no longer exists at this link. This makes this answer useless. – Nate Aug 15 '15 at 23:17