I am trying to toggle on/off airplane mode in IOS 5.1 using private frameworks.
In AppSupport.framework, RadiosPreferences has a property to get/set the airplane mode and set the value
./AppSupport.framework/RadiosPreferences.h:
@property BOOL airplaneMode;
./AppSupport.framework/RadiosPreferences.h:
- (void)setAirplaneMode:(BOOL)arg1;
How can I use these methods? Do I need to use dlsym somehow to create an object and call the methods? Can someone help me with sample code or ways to do it.
As jrtc27 describes in his answer (and I mentioned here), you need to grant your app a special entitlement in order to successfully change the
airplaneModeproperty.Here’s a sample entitlements.xml file to add to your project:
com.apple.radios.plist is the file where the airplane mode preference is actually stored, so that’s what you need write access to.
No, you don’t need to use
dlopenordlsymto access this API. You can add the AppSupport framework to your project directly (with the exception thatAppSupport.frameworkis stored on your Mac under thePrivateFrameworksfolder). Then, just instantiate aRadiosPreferencesobject, and use it normally. The entitlement is the important part.For your code, first use class-dump, or class-dump-z, to generate the RadiosPreferences.h file, and add it to your project. Then:
and do
I’ve only tested this for a jailbroken app. I’m not sure if it’s possible to acquire this entitlement if the device isn’t jailbroken (see Victor Ronin’s comment). But, if this is a jailbreak app, make sure you remember to sign your executable with the entitlements file. I normally sign jailbreak apps with ldid, so if my entitlements file is entitlements.xml, then after building in Xcode without code signing, I would execute
Here’s Saurik’s page on code signing, and entitlements