Redirect to Passcode Settings directly - ios

I can redirect to the "Settings" in an iOS app using the following code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
I'm trying to redirect specifically to the "Touch ID & Passcode" settings within the settings. Is there a way to do this? Assume that the device is capable of Passcode.

You can only open your apps settings bundle or the system 'root' settings.
I have found a blog post that seems to describe what you want, but when I tried it I had no luck, maybe if you persist a bit it will for you.
http://www.pixeldock.com/blog/open-settings-directly-from-your-app/

Apple changes the way to open specific menu in Settings. The value of scheme for iOS 10 is "App-Prefs:". But maybe it will be changed in next versions.
You can try to open different URLs in a cycle.
Remember that the constant UIApplicationOpenSettingsURLString is not defined in iOS 7 (if you support this version).
Please take a look on my code. It works on iOS 10 and lower versions.
// UIApplicationOpenSettingsURLString is available since iOS 8.0
NSString * defaultSettingsStr = ( &UIApplicationOpenSettingsURLString != NULL ? UIApplicationOpenSettingsURLString : #"prefs:root" );
// Array of possible URLs, differ in various iOS versions
NSArray * urlStrs = #[#"App-Prefs:root=TOUCHID_PASSCODE",
#"Prefs:root=TOUCHID_PASSCODE",
defaultSettingsStr];
for (NSString * urlStr in urlStrs) {
NSURL * url = [NSURL URLWithString:urlStr];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
// openURL is deprecated since iOS 10
[[UIApplication sharedApplication] openURL:url];
break;
}
}

There is no way you can directly open particular settings in iOS.
prefs:root and App-Prefs:root both are blocked by apple.
If you use this anyway apple will reject your app.

You can't. iOS only allows redirection to the settings of your specific app.

Related

How does main app know when an sub app has been installed in ios?

How does an app know when an app by the same developer has been installed in iOS?
You can check by openURL method which will help to check app installed in your device or not.
Objective-C:
UIApplication *application = [UIApplication sharedApplication];
NSLog(#"App installed %d",[application canOpenURL:[NSURL URLWithString:#"AppName://"]]);
[application openURL:[NSURL URLWithString:#"AppName://Test"] options:#{} completionHandler:^(BOOL success) {
NSLog(#"Open result %d",success);
}];
Swift:
let appURL = "AppName://extra_param_for_launchscreen"
let URL = NSURL.init(string: appURL)
if UIApplication.sharedApplication().canOpenURL(URL) {
UIApplication.sharedApplication().openURL(URL)
}
by canOpenURL you can check app installed or not.
Note : for iOS 9.0 and grater you need to add
LSApplicationQueriesSchemes in your info.plist file with your app
schema name to white list your app and get installed app status or open app.
Hope this will helps you.
Previously, we can use concept of URL Schemes to find out whether the app we are looking for is installed or not.(By using canOpenURL method). But recently, apple removed this functionality to know whether app installed or not from iOS9 due to privacy policy of apple. So, now you cannot find out the sub app is installed or not in any manner due to security reasons.
Following links might be helpful to you:
canOpenURL to query url schemes
Privacy and URL Schemes in iOS9

Open Keyboard's settings screen in iOS's settings app programmatically from another app

How can we go directly to any of the below mentioned screens of iOS's settings app programmatically
UPDATE
As other users have pointed out this solution does not work anymore with iOS10. If anyone has an idea how to make it work in iOS10, please let us know.
Solution for iOS < 10:
To open the settings (of your own app) you can use the UIApplicationOpenSettingsURLString constant:
if let settingsURL = NSURL(string: UIApplicationOpenSettingsURLString) {
UIApplication.sharedApplication().openURL(settingsURL)
}
This was introduced in iOS 8, so you can use it on devices that run iOS8 or later. But this only opens the settings of your own app. Not the keyboard settings. And if your app does not have its own settings it only opens the Settings app on its main page.
In the old days (before iOS 5.1) you could open a settings URL and directly go to almost any subpage in the Settings app. Apple removed this feature in iOS 5.1.
However it seems to work again in iOS 8 and 9. It is not officially documented by Apple but it seems to work, although I not sure how reliable this is. It works on my iOS 9.1 iPhone but not in the Simulator.
So, with caution, you can try this to open the Keyboard Settings:
if let settingsURL = NSURL(string: "prefs:root=General&path=Keyboard") {
UIApplication.sharedApplication().openURL(settingsURL)
}
Or go even deeper:
if let settingsURL = NSURL(string: "prefs:root=General&path=Keyboard/KEYBOARDS") {
UIApplication.sharedApplication().openURL(settingsURL)
}
Edit:
As iHulk mentioned in the comments you might have to add prefs to the URL schemes in your project's Info.plist file to make this work.
As of iOS 10 "App-Prefs:root" should be used rather than "prefs:root". See below Objective C code. Tested this , code works fine but Apple may reject the app because of this.
Note : As pointed out this will work only on ios 10
NSString *settingsUrl= #"App-Prefs:root=General&path=Keyboard";
if ([[UIApplication sharedApplication] respondsToSelector:#selector(openURL:options:completionHandler:)]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:settingsUrl] options:#{} completionHandler:^(BOOL success) {
NSLog(#"URL opened");
}];
}
Latest message I got from Apple reviewers:
Your app hosts extension(s) but it does not comply with the App Extension Programming Guide.
Specifically, your app brings users directly to the keyboards settings page rather than taking users to the specific settings page for your app. Please ensure that your app only brings users to your app settings page.
When I was redirecting to: prefs:root=General&path=Keyboard/KEYBOARDS

How to open general settings (not in the app settings) from the app in iOS 8?

I know about this
if (&UIApplicationOpenSettingsURLString != NULL) {
NSURL *appSettings = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:appSettings];
}
But I wanna know if its possible to go to the general settings. I need users to enable the keyboard but landing in the app settings confused many users. Any suggestions to open the general settings and even if possible the keyboards section?
You cannot open system apps in iOS. You can show them the path to the message though.
'Settings->General->Keyboard' etc in a modal whenever you wish to display this information to the user.
Starting from iOS 10 the one can use "App-Prefs:root" URL:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"App-Prefs:root"]];

Opening TestFlight app from another app and deep link to specific app

How do i find the scheme of another app and deep link to it from my own iOS app?
More specifically, I want to deep link to the Testflight app upon certain conditions (set by my code). I'm assuming the person has Testflight installed, (which might be a bad assumption but we can live with that assumption).
I know that on Android, you can query for apps and send intents to deep link to someone else's app. What would be the equivalent on iOS?
There are two things you need to do. First, check to see if TestFlight is installed. Then create a new link to your app.
NSURL *customAppURL = [NSURL URLWithString:#"itms-beta://"];
if ([[UIApplication sharedApplication] canOpenURL:customAppURL]) {
// TestFlight is installed
// Special link that includes the app's Apple ID
customAppURL = [NSURL URLWithString:#"https://beta.itunes.apple.com/v1/app/978489855"];
[[UIApplication sharedApplication] openURL:customAppURL];
}
This special https://beta.itunes.apple.com URL will be opened directly in TestFlight.
Finally, if you are using iOS 9 (or later), you need to make an addition to your Info.plist to get the canOpenURL: method to work.
If your app is linked on or after iOS 9.0, you must declare the URL
schemes you want to pass to this method. Do this by using the
LSApplicationQueriesSchemes array in your Xcode project’s Info.plist
file. For each URL scheme you want your app to use with this method,
add it as a string in this array.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>itms-beta</string>
</array>
From looking at the plist the URL scheme for TestFlight is "itms-beta://" I can't manage to get it deep linking yet, I've tried passing it the Apple ID, with and without a ? along with prefixing it with appleid= I will try bundle ID next.
To open the TestFlight app on the users device you can use:
NSURL *customAppURL = [NSURL URLWithString:#"itms-beta://"];
if ([[UIApplication sharedApplication] canOpenURL:customAppURL]) {
[[UIApplication sharedApplication] openURL:customAppURL];
}
Swift 3/4 answer:
if let customAppURL = URL(string: "itms-beta://"){
if(UIApplication.shared.canOpenURL(customAppURL)){
UIApplication.shared.open(customAppURL, options: [:], completionHandler: nil)
}
}
Most of the built-in applications Apple provides respond to custom URL schemes; for example, the Maps, Mail, YouTube, iTunes, and App Store applications will all open in response to custom URLs. However, there are also many established third-party applications with published URL schemes that you can use in your own application. You can search the applications schemes on
http://handleopenurl.com/
http://wiki.akosma.com/IPhone_URL_Schemes – both have a great list of URL schemes
Once you got the custom URL scheme then you can deep link to that app using the same schema,
NSURL *customAppURL = [NSURL URLWithString:#"urlscheme://"];
//Eg: NSURL *whatsappURL = [NSURL URLWithString:#"whatsapp://send?text=Hello%20World!"];
if ([[UIApplication sharedApplication] canOpenURL:whatsAppURL]) {
[[UIApplication sharedApplication] openURL:whatsAppURL]]];
}
Another way to invoke either one app or another:
- (IBAction)go:(id)sender {
NSString *cnnAppURL = #"cnn://";
NSString *mapsAppURL = #"maps://";
BOOL canOpenURL = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:cnnAppURL]];
NSString *url = canOpenURL ? cnnAppURL : mapsAppURL;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
Please read "UseYourLoaf's recent blog post on using URLschemes with canOpenURL. This relates to new security concerns and solutions. Quote:
"This is useful but developers including Twitter and Facebook were using this mechanism to discover the list of Apps installed on a device so they can deliver “tailored content”. Apple decided this is a privacy violation and so in iOS 9 restricted the querying of URL schemes. If you build and link against the iOS 9 SDK you need to whitelist the schemes your app will query. What is important to understand is that this policy can also impact older Apps that have not yet been rebuilt with the iOS 9 SDK."
Please read this link on issues related to the canOpenURL function
Read #picciano's last point - this won't work without modifying your app's plist.

Open setting from my app

I am using iCloud for core data. if user is not logged in on iCloud i want to take him to setting page, is it possible in ios.
Thanks
If you are writing app for iOS < 5.1 then you can use custom URL schemes - find list here.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: myUrlString ]]; //find myUrlString in link above
But this feature was removed in iOS 5.1 and most likely won't available in the feature

Resources