Is there a way to open the app store to a specific application?
I tried using something like the following:
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:#"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284417350&mt=8&uo=6"]];
But got the following: "Safari cannot open the page because to many redirects occurred".
Apparently this issue only affects the simulator. A build an go on the device works perfect.
Use http://itunes.com/app/YourAppNameWithoutSpaces
See also this.
Another simple way is:
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:#"itms-apps://itunes.com/app/YourAppNameWithoutSpaces"]];
This is very clean
You can open app without opening safari
NSString *appId = #"you appid"; //like 999999999
NSString *link = [#"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=" stringByAppendingString:appId];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:link]];
Replace iTunesLink with your App URL.
NSString *iTunesLink = #"https://itunes.apple.com/us/app/digital-speedometer-pro/id1021728349?mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
Starting from iOS 6 right way to go is using SKStoreProductViewController class.
Code is here: https://stackoverflow.com/a/32008404/1151916
Related
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
its work fine for other settings like :
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=General&path=Keyboard"]];
or wifi or general
Its crashing with Message from debugger: Terminated due to signal 9 for only UIApplicationOpenSettingsURLString when switch state change ON/OFF
else if we don't change switch state change ON/OFF then it debug properly, visit all the delegate methods.
I need to open the bluetooth settings menu in IOS10 and above.But [[UIApplication sharedApplication] openURL:
[NSURL URLWithString:#"prefs:root=Bluetooth"]]; is not working in ios 10.
After exploring multiple document I got below link which provide code which will work properly. https://gist.github.com/johnny77221/bcaa5384a242b64bfd0b8a715f48e69f
But, Now I have question will app store accept this patch code or they will reject application.
Please help me to solve this issue.
Thanks in advance
Swift 3.0:- Working in all iOS version upto iOS 10.2
let url = URL(string: "App-Prefs:root") //for system setting app
#IBAction func blutootheButtonTapped(_ sender: AnyObject) {
let url = URL(string: "App-Prefs:root=Bluetooth") //for bluetooth setting
let app = UIApplication.shared
app.openURL(url!)
}
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.
NSString *settingsUrl= #"App-Prefs:root=Bluetooth";
if ([[UIApplication sharedApplication] respondsToSelector:#selector(openURL:options:completionHandler:)]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:settingsUrl] options:#{} completionHandler:^(BOOL success) {
NSLog(#"URL opened");
}];
}
Hi friends,
I am getting data from server when user post a link on his timeline am displaying like this but my requirement is when i click Title then it will open browser. How can i do this?
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.stackoverflow.com"]];
Will open a URL by the Application defined for the scheme. http has Safari as default (I guess)
To open it in the App itself create a ViewController + xib,
add a UIWebView to your View
& Buttons to get back to the app.
Then you can create an instance of your new ViewController and present it with
[self presentViewController:WebVC animated:YES completion:^(void){
[[WebVC MyWebView] loadRequest: [NSMutableURLRequest requestWithURL:[NSURL URLWithString: #"http://stackoverflow.com"]];
}];
e.g.
To make it even easier you could add a function to your ViewController like this one
-(void) LoadUrlFromString: (NSString *)url{
[self.MyWebView loadRequest: [NSMutableURLRequest requestWithURL:[NSURL URLWithString: url]]];
}
and then just do as before but call
[WebVC LoadUrlFromString:#"http://stackoverflow.com"];
on completition
You can use TTTAttributedlabel
TTTAttributedlabel *title_lbl = [TTTAttributedlabel alloc]init] //Make it an instance of TTTAttributed label what you are using for displaying the Title.
NSRange range = [title_lbl.text rangeOfString:"YOUR_TILE_HERE (Latest bollywod and hollywood.....")"];
[title_lbl addLinkToURL:[NSURL URLWithString:#"YOUR_URL_HERE (www.bollywood.com)"] withRange:range];
title_lbl.delegate = self;
And for onlcick method
- (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url
{
NSlog("%#",label.text);
[UIApplication sharedApplication] openURL:url];
}
I am building with Xcode 5/iOS SDK 6.1. If the app runs on an iOS 7.x device it should check whether the setting "Settings -> General -> BackgroundAppRefresh" is set for the app. Since this property is only available on iOS 7 I am doing:
if([[UIApplication sharedApplication] respondsToSelector:#selector(backgroundRefreshStatus)])
{
NSInteger outcome=[[[UIApplication sharedApplication] performSelector:#selector(backgroundRefreshStatus)] integerValue];
//do something with "outcome"
}
However... the app crashes on iOS 7 at the "performSelector" line which is strange because it passes the "respondsToSelector" call?? Anyone knows why? I also tried NSSelectorFromString(#"backgroundRefreshStatus") with the same result.
You've got a lot of unnecessary code there. Unless the backgroundRefreshStatus selector exists before iOS 7 as a private API you don't need the version check.
Your use of #selector is also incorrect and you don't need to use performSelector, just call the method:
if ([[UIApplication sharedApplication] respondsToSelector:#selector(backgroundRefreshStatus)]) {
UIBackgroundRefreshStatus refreshStatus = [[UIApplication sharedApplication] backgroundRefreshStatus];
}
You are using a string as the selector. Try without the string:
UIApplication *app = [UIApplication sharedApplication];
if([app respondsToSelector:#selector(backgroundRefreshStatus)])
{
UIBackgroundRefreshStatus outcome = [app performSelector:#selector(backgroundRefreshStatus)];
// or outcome = [app backgroundRefreshStatus]
}
I am making a twitter application for iPhone, I am trying to add a button which will open Safari, and take the user to their twitter homepage. I have a textfield called username, so the following code does not work, hopefully someone will be able to help me out.
-(IBAction)viewAccount {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.twitter.com/", username.text]];
}
Any help is appreciated! Thank you!
Try this
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://www.twitter.com/%#", username.text]]];
Check if your URL is correct
NSURL* twitterURL = [NSURL URLWithString:#"http://www.twitter.com/", username.text];
NSLog(#"my twitter url: %#", twitterURL);
edit: seems someone was faster than me ;)