Accessing Settings app values and opening it if needed - ios

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.

Related

Open iOS Settings App (top level - not deep link into the App Settings page) - iOS 12/13

I'm working on a iOS App which interacts with different hardware. We access and configure these devices using a "Soft AP" work flow (ie hotspot)
Our preference is to use NEHotspotConfigurationManager to automate the process for the user and in most cases this works fine.
However, in those edge cases where it doesn't (ie iOS 13+ and location services) we'd like to make the workflow as simple for the user as possible.
Currently we have a nice list of steps that the user needs to take:
Press/swipe home
Open Settings
Navigate to WiFi settings
Find and tap the specified WiFi SSID
Return to the App
It's really not pleasant at all.
I'm aware that there is not official way to open the WiFi settings and I can live with that, but recently I was mucking around with the Wyze App and pairing one of their light bulbs and noted that they have manual workflow which opens the top level Settings page - NOT the App's settings. (nb: The Wyze App also has "app settings")
So, after some more reading, I find that UIApplication.openSettingsURLString will open the App's specific settings page, which is cool and everything, but this is not what I need. I'd be really awesome if it was "officially" possible to launch the iOS Settings App and NOT have it open the App's settings, but just land on the top level page.
I know if the App has no settings, this is the behaviour I will get, but our App does (and I can't be changed)
I don't want to/can't use URL schemes like prefs:root unless it can be guaranteed not to be rejected by Apple!
And, yes, I look at a lot of different blogs and questions on the subject, including A Comprehensive Guide to All 120+ Settings URLs Supported by iOS and iPadOS 13.1 - but I'd like to not have the App rejected

is it possible to turn off wifi or switch iPhone to offline mode in codes in swift 4?

I want to know is there any way to turn on or off the iPhone wifi or switch the device to offline mode in codes in swift 4 or not
I know that apple may not allow the app can do such things to be distributed in App Store But it's Not important I just want to know is there any codes to do that or not (Just in swift 4)
5 Solutions Collect From Internet About “How to turn off internet connection, bluetooth and WIFI programmatically?”
Ans
You can’t. Apple does not allow 3rd party apps to change global system settings like that.
There is no API available to control cellular data,wi-fi,bluetooth within in an app , User have to go to settings to enable or disable cellular data,wi-fi and bluetooth.
This is not possible in iOS unless you jailbroke your device. Apple is not allowing any apps developer to access wifi/bluetooth. You can only check wifi/tooth is connected or not.
You can’t do that using the iOS application. Apple not allowing it.
Legally there is no way to do it. Even somehow if you are manage to do it, Apple will reject your app while submitting to AppStore.
update
I am not sure the following code will work or not, try once, initially add the header file to your project folder and create the bridging header to your code ,then use the below code where you need , for ref purpose I taken the answer from here
var tempSBWifiManager: SBWiFiManager = objc_getClass("SBWiFiManager")
// Steal a class from SpringBoard
tempSBWifiManager.sharedInstance().isWiFiEnabled = false

Is there any way to show Settings app in iOS7

I want to show defaul Settings app. Before I could use method
NSURL*url=[NSURL URLWithString:#"prefs:root=WIFI"];
But now it's disabled, is there any way now in iOS7 to show Settings app?
Unfortunately this is not possible anymore, as apps were offering jailbreak like solutions through the app store(Settings shortcuts). See the following link iOS Launching Settings -> Restrictions URL Scheme. Infact, its been disable since iOS 5.1.
See the following link for an article that shows when and why this was removed in detail: http://www.idownloadblog.com/2011/11/29/iphone-5-1-disables-shortcuts/

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.

How to get a list of your iphone apps

How can i get a list of all my iphone apps (even pointers for each app will be helpful)?
I'm developing an app which contain some screen that should have a list of all my installed apps (with their icon) and the option to select one to launch it in the future depends in other function of mine.
Thanks alot!
There's no way to accomplish this, because each app is sandboxed.
You would be able to determine if select apps are installed if they have custom URL schemes. For example, the Facebook app can be launched with the custom url scheme "fb://", but these aren't guaranteed to be unique, so a different app could use a scheme that's well known to belong to another app. Also not all apps have a custom URL scheme, and you would need some master list (that would need to be constantly updated to be accurate) to check for the presence of each. So you could maybe detect a select list of well-known apps with custom URL schemes, but never get a list of all of them.
If you just wanted to detect your own apps, you could have custom URL schemes that are almost certainly going to be unique set for each app, and check for those.
You could also jailbreak your device, but I'm assuming you want this functionality in an app that is distributed on the app store, so you wouldn't be able to add functionality that requires a jailbreak to work.
EDIT:
Here's an example showing detection of the Facebook app being installed:
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"fb://"]])
{
// Handle the Facebook app being installed
}
Note however, this won't give you any information about the app. Any app developer could add the "fb://" custom url scheme to their app, which would make this falsely detect it.
If you want to find lists of custom url schemes for iOS apps, just search in Google.
another way to look at this is to present the user with all of your app in the appstore. If they have any apps installed on their device then in iOS 7 they will see a button called "Open" next to each of them.
For example you can have a UITableViewCell or a UIButton that says "Checkout Our Apps". In the code you would add this.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"itms://itunes.com/apps/sixaxisllc"]];
Replace SixAxis LLC with your iTunes developer name and when users click on it, it will launch AppStore app with only your apps are shown. (With Open or price amount next to each of them)
NOTE: test this on actual device and not in simulator
Because of the Sandboxed environment, all you can do is test if it you can open a custom URL.
Akosma Software maintains a list of popular Url on his wiki: IPhone URL Schemes.

Resources