In many applications, such as the Mail app, if the device is in airplane mode a notification will pop up that says "Turn Off Airplane Mode or Use Wi-Fi to Access Data."
I thought that this would automatically be invoked if my app tries to access the internet, but it is not. Is there a special method to do this, or if not how can I check if the device is in airplane mode and provide a link to Settings to disable it?
If you add the UIRequiresPersistentWifi key to your Info.plist and set it to YES, then if you're in Airplane mode, you'll get the standard "Turn Off Airplane Mode..." popup on launch.
I test in my app. I find it changed. "UIRequiresPersistentWifi" => "Application uses Wi-Fi".
I hope it will help somebody.
You could use the apple's reachablity framework when you app launches to check for network connectivity. Check this out
http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html
I have a wrapper class for reachbiltiy APIs to make it simpler to use. (ASIHTTPRequest has one as well).
https://github.com/daltoniam/GPHTTPRequest
see the GPReachablity class for checking for connectivity. As far as a dialog prompt, not sure there is a way to push to the settings app. Any questions let me know.
If you want the standard Turn Off Airplane Mode or Use Wi-Fi to Access Data [settings | ok]
Add a new property in your info.plist by clicking the + sign at the top.
The new property is called UIRequiresPersistentWiFi (this is similar to postings above, but needs to be exact otherwise it doesn't register)
Change type from String to Boolean
Change value from NO to YES
Clean and rebuild your app
Take a look at this. Apparently, Airport control was moved by Apple into a separate framework
It seems there is no standard way to notify the user to turn airplane mode back on. As you mentioned, this obviously isn't very elegant, so I assume apple deleted this feature.
Related
I am developing an iPhone app, that will not be distributed on AppStores. I have tried to search for private api but no luck. When the user tries to quit the app, I want to prompt the user to enter the correct password so as to enable him to exit the app. How can I achieve this? Thanks in advance.
Cheers!!
It sounds like you need something similar to iOS "Kiosk Mode" as described in this answer:
Put an iPhone or iPad into 'Store Demo' mode
Using that description in conjunction with the following steps might achieve precisely what you want:
Have a "Quit" button
Show a password dialogue when it is pressed
If it was correct, read an out of bounds array location (or do whatever) to crash the app
With that config installed you'd get stuck in whatever app you launch next, though.
You can't! You'll have to password protect the launch instead.
If you want to prevent the user from quitting your app, you'll need to physically cover the home button. This isn't a bad solution if your goal is to do something like a kiosk or a point of sale system, where you probably want to mount an iPad in a secure enclosure to prevent tampering or theft anyway. There are quite a few such enclosures on the market in a variety of styles.
For a normal app, though, there's really no solution -- iOS isn't designed for whatever you're trying to do.
The only way I could think to do what you want (which is to prevent access to certain apps) would be to replace the SpringBoard application (this is the method used by Apple itself in the App store models of the iPhone and iPad that restrict the things you can do on the devices). #owenfi pointed at one way to do that without jailbreaking, but in general it is limited: you won't be able to "exit" the app, you will basically just be able to run a single app.
I want to display iPhone's settings Airplane feature and autolock feature's status in my app.
I got the two links : link1 and link2 but did not get the much details on that.
Can any one tell me how can I get those status?
basically, you can't. you can disable autolock while your application is running, but you can't change the system setting.. nor can you access it. rather than displaying the airplane mode status, maybe you can show general reachability? i.e. https://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html or ASIHTTP includes reachability functionality.
UPDATE: As of some version of iOS 8 (8.3, maybe), GPS hardware can be turned on even in airplane mode (i.e., you can get GPS location even in airplane mode). This renders this question moot.
--
Is it possible to programatically determine if an iPhone is in Airplane Mode? I specifically want to know if it's in AirPlane Mode, as opposed to having (or not having) a network connection. This question has been asked a lot, but every answer I've seen has referred to Apple's Reachability code to determine if a network connection is available.
I'm writing an app that uses the iPhone's GPS. At the moment, if Airplane Mode is on and my app is launched, my location manager object still appears to exist and still appears to be giving me a (cached?) location. The little GPS icon appears in the status bar to let me know that my app is determining a location.
I want to know if the phone's in Airplane Mode so that I can not initialise the location manager object and I can change my UI to indicate to the user that GPS functionality is not available.
The GPS functionality can obviously be used regardless of network connectivity, so a lack of network connectivity strikes me as being a poor proxy for Airplane Mode. I don't appear to get any specific errors (through locationManager: didFailWithError) when in Airplane Mode, just a generic error that I'm assuming could come from a number of sources.
Similar requirements for my app, except I knew in advance that it would most likely be used in a "no cell signal" environment (camping in a remote area) and that the user might put the device in airplane mode to conserve batteries, without realizing it shuts down GPS.
Since airplane mode does not result in an didFailWithError, and locationServicesEnabled returns yes, I set a timer for 60 seconds, and if no GPS reading is returned before the timer expires, I display a message to the user telling them that GPS data can't be read, and suggest they check that airplane mode is not enabled, and that they ensure they have a clear view of the sky.
I don't know if it is possible to get this information, at least using public classes, but if what you need is to alert the user that he's in Airplane Mode, so with limited app functionality, you may set in your Info.plist file the UIRequiresPersistentWiFi property to "true". Then when Airplane mode is set you will get this message.
By the way note that this approach is better than just checking the Airplane Mode status, other than because it is system supported, as if the user enables Airplane mode and then re-enables Wi-Fi (still staying in Airplane Mode) then the system alert will not be displayed.
One solution might be to take a screenshot of the device and look at the colors present in that region. If they're orange, you're in airplane mode.
You really shouldn't be trying to check if Airplane Mode is enabled or not. What if Apple makes a change to how Airplane Mode works, where it will leave the GPS equipment enabled even when turned on? The best way to reliably detect whether GPS services are enabled is to implement the CLLocationManagerDelegate and let the APIs tell you whether GPS is available or not
Examining the NSError it may pass to you will let you know if there are problems to
Ok, so we all are aware (or should be) that 'UIApplicationExitsOnSuspend' can be set true or false in the info.plist file.
What I would like to know please, if possible, is if we can change the bool value of UIApplicationExitsOnSuspend in app.
Simply allowing the user to set whether the app is allowed to run in background, or wether it should just kill itself on the pressing of the home button.
Any help please.
It's not possible to change the value in the app.
However you could add a setting to your app and check wheter it's on/off in applicationDidEnterBackground:.
Something like:
if (theUserDoesNotWantMultitasking) {
exit(0); // doesn't generate a crash report.
}
It seems tolerated by Apple validation process even though I bet they're not recommending it.
Small precision:
By tolerated, I mean that I've done that once in an app, with a different use case (not based on a user setting). It has been approved, but I can't guarantee that it will always be the case.
It's not possible.
Calling exit from your app is going against Apple's advice. If you do so, you may find your app rejected at some future point.
Read the best practices: http://developer.apple.com/library/ios/#DOCUMENTATION/UserExperience/Conceptual/MobileHIG/UEBestPractices/UEBestPractices.html
I live in Canada, so am fortunate that I can tether. One issue is that to toggle tethering, you need to drill down four screens in Settings, which is just a big hassle.
A Google search returned nothing, so I was wondering if anyone here knew the code to turn on/off tethering?
I know there's a toggle for SBSettings, but I do not have a jailbroken phone, I just want to create an app I build onto my phone and have an icon for quickly toggling it.
Thanks
You cannot alter phone settings from within an application using any APIs allowed by the iPhone SDK. As you point out - there is an SBSettings toggle - which relies on a Private API (which you agree not to use when you get the iPhone SDK from Apple, incidentally).
There is a file located in the Preferences folder, along with the com.apple.SpringBoard.plist:
/var/mobile/Library/Preferences/com.apple.MobileInternetSharing.plist
In that file, you will want to set 1023 for key State to enable the Tethering feature. To disable the feature, you will want to set 1022 for key State.
This action is only possible on a jailbroken device