Url Scheme for ADVERTISING iOS 12.0 - ios

I used:
NSURL *url = [NSURL URLWithString:#"App-Prefs:root=Privacy&path=ADVERTISING"];
[[UIApplication sharedApplication] openURL:url];
it worked on iOS 11.x and before.
but with iOS 12.x it doesn't work.

Apple no longer allows prefs:root= via section 2.5.1 in their guidelines (they now consider what you're doing a non-public URL scheme).
The best you can do is open up your app settings and the top level should be simple enough that the user can get to where they need from there.
Perhaps something like:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

Related

How to open default music app into my application ios 10

Based in this link.
Works perfect but me in old ios versions, but in ios 10 not works.
This is my code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"music://"]];
I'm testing with
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"music://"] options:#{} completionHandler:nil];
but it does not work
Just add Privacy - Media Library Usage Description in .plist. That solves the problem

why can't I open facebook and twitter app with ios 9

Before ios9 comes, I used following code to open facebook app with my app when button clicked.using this if the phone has facebook app, it opens the facebook app and, if it is not, it opens the safari browser.same for the twitter.this is my code.
- (IBAction)facebookButton:(id)sender {
NSURL *facebookUrl = [NSURL URLWithString:#"fb://profile/number"];
if ([[UIApplication sharedApplication] canOpenURL:facebookUrl]) {
[[UIApplication sharedApplication] openURL:facebookUrl];
}
else{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.facebook.com/number"]];
}
}
- (IBAction)twitterButton:(id)sender {
NSURL *twitterUrl = [NSURL URLWithString:#"twitter://profile/"];
if ([[UIApplication sharedApplication] canOpenURL:twitterUrl]) {
[[UIApplication sharedApplication] openURL:twitterUrl];
}
else{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.twitter.com/"]];
}
}
this worked fine, before iOS 9.but now if app exists or not, it only opens with safari.help me with this
we have to add followings in info.plist
From Apple documentation on canOpenURL: method:
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.
If your (iOS 9.0 or later) app calls this method using a scheme you
have not declared, the method returns NO, whether or not an
appropriate app for the scheme is installed on the device.
Unlike this method, the openURL: method is not constrained by the
LSApplicationQueriesSchemes requirement: If an app that handles a
scheme is installed on the device, the openURL: method works, whether
or not you have declared the scheme.
Apple add this change to API, because canOpenURL: method was often used to receive information about applications, installed on user device, without actual openURL: calls.
Issue can be resolved in the following ways:
Add "fb" and "twitter" URL schemes into LSApplicationQueriesSchemes array in your Info.plist;
openURL: method returns NO if URL wasn't successfully opened. You can rewrite code in following way to avoid canOpenURL: call:
if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"fb://profile/number"]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.facebook.com/number"]];
}
Look into Universal Links, that works in similar way - open application, if it is available on device, otherwise URL is opened in Safari.
Custom deep linking schemas does not work on iOS9 anymore. You need to use Universal Links. See this guide.

Redirect to Passcode Settings directly

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.

Opening Settings Application

Would the following be considered as private API use? After googling I have found many conflicting reports.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs://"]];
Also does anyone have a list of valid urls within the settings application? For example:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs://notifications"]];
will open the notifications page of the settings application.
I have found the answer to my own question.
It is supported in iOS5.
URL Schemes can be found here: http://maniacdev.com/2011/11/tutorial-using-url-schemes-to-open-the-settings-app-to-a-specific-page-in-ios-5/

Launching settings app from custom iOS application

Is there any way to launch the build-in iOS settings application from our custom applications.
Based on the URL schema , it is possible to launch safari,maps,YouTube,iTunes... etc. But in the documentation there is no any info related with settings app.
TIA.
-Balaji R.
//code for opening settings app in iOS 8
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
//code for opening settings App in ios5
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=WIFI"]];
No you can not. Opening the Settings app from another app

Resources