How to show alert to activate cellullar data iOS - ios

How to check in my iOS app if my cellullar data are turned off, and show this alert to navigate to it on settings and turn it on.
For example check the image!

Apple has some sample code available named Reachability which you can use to see if the Internet is available.
If WiFi is down, you can bring up your own "You can turn on cellular data for this app" UIAlertView.

Well, iOS 5.1 removed the ability to open Settings, so basically you can't do it in iOS >= 5.1
for iOS < 5.1 was something like that
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=General&path=Network"]]

Related

iOS: send user direct to health privacy settings

I am aware of how to generally open the settings from inside an iOS app, but is there a way to send them to settings > privacy > health? It seems this would be a standard thing to do, but I'm not seeing guidance on this in the docs.
Thanks for any suggestions.
As of iOS 9.3 there is no API for opening the Settings app on iOS directly to Settings > Privacy > Health. You should file an enhancement request with Apple.
You can navigate to settings of your app:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
As for the health kit, you prompt for the authorization, right? that's where the users should set everything. I don't know if you actually can show the authorization again to change the settings.

Open Settings from App (like Twitter to turn on Wi-Fi) - With iOS 7.1

I know that there are a lot of Q&A saying that from iOS 5.1 it is not possible to open Settings from the app, some examples:
Opening the Settings app from another app
is it possible to open Settings App using openURL?
launch settings from alert
But what is really annoying is that Twitter App (version 6.2.1, iPhone 4s, iOS 7.1) is opening Settings from the application.
Check this image:
Clicking on Settings, Twitter is opening Settings and a view with title Wi-Fi. It is true that this view do not have all the Wi-Fi properties. However, it is something into Settings.
How is that possible? How is handling Twitter with that?
Someone have a clue?
That is not the Twitter app showing the alert. That is a standard iOS alert that can appear when an app tries to use location services with no WiFi.
No 3rd party app can directly show that alert. iOS shows it and iOS takes you to the Settings app.
I just verified this with my own app. If the app already has permission to use location services, then if you do something in the app that requires location, this alert will appear when appropriate. I know for a fact that I do nothing in my code to make the alert appear but it does appear.

iOS CoreLocation: How to handle programmatically if location services are disabled from device settings

I am trying to get the geolocation of the iOS device. I am able to get the coordinates of the present location using CoreLocation framework.
But the problem is I have to handle the scenario when location services has been disabled from device settings. In that case, I have to redirect the user to settings from within my app as per the requirement.
I know that I can do this using the below scheme prior to iOS 5.1
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs://"]];
But, how to handle this in this newer releases. I am stuck with this since a long time and no solution yet. Please advise.
You should call:
[CLLocationManager locationServicesEnabled]
As it states here:
http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html
#Rashmi - You might be getting some trouble some where else.
CoreLocation Framework automatically detects if the Location Settings are disabled from the Device via generating an alert and take you automatically to the device settings.I had verified this in iOS7, iOS6 devices.
Moreover, I Googled and found that this is the only way to open setting from the app and that matches with you have written.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs://"]];
You can also follow this URL for reference
Open Device Settings from the app
For Core Location, You can see this demo CoreLocation

Accessing Settings app values and opening it if needed

I have seen that there are known apps, such as Twitter and Facebook, that display a "Turn Off Airplane Mode or Use Wi-Fi to Access Data" message within an alert view, with a button that switches to the Settings app, when no network is detected as the app goes foreground. This message is the same in all apps where I saw it, is this alert view a kind of predefined one that you can use? Similar to the one displayed when checking locationServicesEnabled...
I found some posts dealing with this issue some time ago, for example:
iOS UIAlertView button to go to Setting App, and it seems (or seemed) to be a way to read the values in the iOS' Settings app, but I couldn't find any of this in the Apple Developer's documentation... is there any public API for accessing those values? Would an app be rejected if accessing them as in the post I linked?
Thanks in advance
Till iOS 5.0, you can use the URL scheme to open the Settings App from third-party apps using the URLScheme like:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=WIFI"]];
Unfortunately, iOS 5.1 and iOS 6 not supports this feature.
You can use the Reachability for checking the Wi-Fi state.
For displaying the default alertview when the Wi-fi is off or in AirPlane mode you can use the Application uses Wi-Fi flag in the info.plist
Refer InfoPlistKeyReference for details:
UIRequiresPersistentWiFi
“Application uses Wi-Fi”
Specifies whether this app requires a Wi-Fi connection.

Howto Access WiFi Settings programmatically in iOS 5.1

I'm looking for a smart way letting the user of my app connect to a WiFi Network. I know how to detect if the device is connected or not. I tried to use URL's to direct the User to the correct prefs Page. Unfortunately this doesn't work anymore. Any suggestions on howto require users to connect to WiFi???
thanks for helping!!!
Try using it to access the WiFi settings in iOS 5.1
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=WIFI"]];
Try using it to access the WiFi settings in iOS 9
if (&UIApplicationOpenSettingsURLString != NULL) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=WIFI"]];
}
Try to add prefs tu URL schemes like stackoverflow.com/a/31253743/3668465 did.
You can use this option for identify a SSID:
iOS >= 4.1 it's possible to obtain SSID of wireless network that device is currenctly connected to.
For this you'd use function CNCopyCurrentNetworkInfo
Details on implemenation: iPhone get SSID without private library
question example -> how to programmatically open the WIFI settings in objective c in iOS9

Resources