Toggling AirPlane mode in iOS Programmatically
Asked Answered
P

2

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).

Pseudo answered 9/12, 2013 at 11:26 Comment(7)
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.Month
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...Pseudo
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: forums.imore.com/siri/…Month
yaa, that's the last way, if i dont get the answer of this...Pseudo
Check This Answers #794424Incommode
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)Pseudo
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 .Windrow
N
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.

Negro answered 20/2, 2014 at 2:59 Comment(2)
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.Pseudo
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 : youtube.com/watch?v=ZcjtEKNP05c . Is this a fake or something?Pontiac
B
-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.

Barbarize answered 2/5, 2014 at 7:11 Comment(3)
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 frameworksPseudo
I know this is an old answer, but I was wondering if you could re-upload the ToggleAirplane sample project. Thanks!Austere
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.Mallorymallow

© 2022 - 2024 — McMap. All rights reserved.