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
Related
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]];
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.
I want to create app which will detect and show the list of all running application and i can close other application from that app.
Below is the code to open the application. But is their any way to close the another running applications
NSString *customURL = #"iOSDevTips://";
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:customURL]])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]];
}
Is this possible in objective C or swift?
If yes what are the chances for its acceptance by apple review team
No. You can't do that in iOS.
Don't worry about what other applications are open. The OS will take care of closing them if necessary.
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/
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