Rate button (link to my app on App Store) not doing anything - app-store

Here's the creation of my button:
- (void)rateInfo {
UIButton *rate = [UIButton rateCreate];
[rate addTarget:self action:#selector(rateButton:) forControlEvents:UIControlEvenTouchUpInside];
[self.view addSubview:rate];
rate.frame = _mainLayout.rate;
}
Here's the rateButton: method:
#define YOUR_APP_STORE_ID XXXXXXXXXX
// and yes, I have my actual number in the code
/*
*
*
*
/
static NSString *const iOS7AppStoreURLFormat = #"itms-apps://itunes.apple.com/app/id%d";
static NSString *const iOSAppStoreURLFormat = #"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d";
-(IBAction)rateButton:(id)sender {
[NSURL URLWithString:[NSString stringWithFormat:([[UIDevice currentDevice].systemVersion floatValue] >= 7.0f)? iOS7AppStoreURLFormat: iOSAppStoreURLFormat, YOUR_APP_STORE_ID]];
}
Is that how I'm supposed to write this out? When you tap the rate button, it generates the URL? If so, I don't know why it's not working.
Two things:
1. My app just went live on the store (it's a puzzle game called Twinstones if you want to try it out).
2. I'm signed into Apple when I'm trying to connect

rateButton: method is just creating the URL. You should tell the application to open the URL. You can do it like;
NSURL *appStoreURL = [NSURL URLWithString:[NSString stringWithFormat: iOS7AppStoreURLFormat, YOUR_APP_STORE_ID]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appStoreURL]];
removed the iOS version check because old URL isn't working anymore.

Related

How to open a apple maps application with directions from my ios application

My aim is to open a map application from ios application with directions, I am able to open maps application but it is not showing directions, i have written the code as follows
NSString *mystr=[[NSString alloc] initWithFormat:#"http://maps.apple.com/maps?saddr=Current+Location&daddr=Newyork"];
NSURL *myurl=[[NSURL alloc] initWithString:mystr];
[[UIApplication sharedApplication] openURL:myurl];
Can any one please help me how figure out how to pass parameters to this url and any other?
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(self.location.latitude,self.location.longitude);
//create MKMapItem out of coordinates
MKPlacemark* placeMark = [[MKPlacemark alloc] initWithCoordinate:coordinate addressDictionary:nil];
MKMapItem* destination = [[MKMapItem alloc] initWithPlacemark:placeMark];
if([destination respondsToSelector:#selector(openInMapsWithLaunchOptions:)])
{
//using iOS6 native maps app
if(_mode == 1)
{
[destination openInMapsWithLaunchOptions:#{MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeWalking}];
}
if(_mode == 2)
{
[destination openInMapsWithLaunchOptions:#{MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving}];
}
if(_mode == 3)
{
[destination openInMapsWithLaunchOptions:#{MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeTransit}];
}
} else{
//using iOS 5 which has the Google Maps application
NSString* url = [NSString stringWithFormat: #"http://maps.google.com/maps?saddr=Current+Location&daddr=%f,%f", self.location.latitude, self.location.longitude];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
}
If you mean taking the user to the maps application based on two points, then you can do it like this:
Create an NSURL that looks like this:
NSURL *URL = [NSURL URLWithString:#"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f"];
You plug in your starting address and destination (in lat. and long.) appropriately.
Tell your application to open the URL
[[UIApplication sharedApplication] openURL:URL];
It should take you to the maps application automatically!

iPhone 4 problems dialing from inside app

There is an iOS 5.0+ app, released in App Store, which displays employees profiles with their phone numbers. The users of the app can tap on the phone number and the number will be dialed on their iPhones.
The problem is that some users with iPhone 4 are reporting that it does NOT dial.
This is the code I am using to dial:
NSString *cleanedString = [[self.member.phone componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:#"0123456789-+()"] invertedSet]] componentsJoinedByString:#""];
NSString *escapedPhoneNumber = [cleanedString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *urlText = [NSURL URLWithString:[NSString stringWithFormat:#"tel://%#", escapedPhoneNumber]];
[[UIApplication sharedApplication] openURL:urlText];
Any ideas about this?
There shouldn't be any / in the tel: scheme:
NSURL *urlText = [NSURL URLWithString:[NSString stringWithFormat:#"tel:%#", escapedPhoneNumber]];
In the Apple URL Scheme Reference you can see some example for what is allowed in the tel: scheme.
If you use telpromt instead of tel this will return you to app after your call ends|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"telprompt:1234567890"]];

how to stay on application in iphone when you call someone from application?

I am calling a number from my application, using following code, but it will transfer control tou application call"All Contact" as I end the call, but I want to stay on same page, as I end the call,
NSString *str = [NSString stringWithFormat:#"tel://%#", number_display.text];
NSURL *url = [ [ NSURL alloc ]
initWithString:str];
[[UIApplication sharedApplication] openURL:url];
how can I do it ?
Only the user can switch back to your app. And Apple has implemented the 4/5 finger swipe for quick access.

How to open Maps app from my code to show directions?

HI.. I have to show directions between two coordinates. I'd like to open Maps app, passing the start and end coordinates from my code.
I don't want to open it in the Google maps, which opens in browser(Safari). I tried that method. That was working perfect.
NSString* urlStr = [NSString stringWithFormat: #"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", s_lat, s_long, d_lat, d_long];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:urlStr]];
But, I want to open iPhone Maps app. How can i do this? Is this possible? Any help will be appreciated.
Try it on a real device. I'm using the same code and it opens Safari at the simulator and iPhone Maps at the device.
Hey Simon the method you are using is
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:urlStr]];
will only open safari.So there is no chance that with open url you would open a diiferent thing.You can use the UIWebView for this and then load the webview with the url.I think that would be the simple thing like this
views=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
[views setBackgroundColor:[UIColor lightGrayColor]];
NSString* urlStr = [NSString stringWithFormat: #"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", s_lat, s_long, d_lat, d_long];
NSURL *url=[NSURL URLWithString:urlStr];
NSURLRequest *req=[NSURLRequest requestWithURL:url];
//[views loadHTMLString:googlePage baseURL:requestURL];
[views loadRequest:req];
self.view=views;
And if you even don't want to use this then then you can use the MapKit provided in your XCode Frameworks.Hope this would help you.

How to make a call from my application, without quitting my application in iPhone?

I Know how to make a call directly from my application programmatically in iPhone, but before invoking the call , my application is terminating, which is not expected to, my application has to resume back, once the call is quit. How to do this for iPhone programmatically?
Thank You.
See this thread, you can take the code snippet from there as is and use it
making a phone call w/o quitting an appication
Keep in mind that it's possible only from iOS 3.1. If you targeting iOS 3.0 there is no way not to quit the application.
NSString *callString = [NSString stringWithFormat:#"tel:%#", #"412-33-44-55"];
NSURL *url= [NSURL URLWithString:callString];
NSString *osVersion = [[UIDevice currentDevice] systemVersion];
if ([osVersion compare: #"3.1" options: NSNumericSearch] >= NSOrderedSame ) {
UIWebView *webview = [[UIWebView alloc] initWithFrame:[callButton frame]];
webview.alpha = 0.0;
[webview loadRequest:[NSURLRequest requestWithURL:url]];
// Assume we are in a view controller and have access to self.view
[self.view insertSubview:webview belowSubview:callButton];
[webview release];
}
else {
// On 3.0 and below, dial as usual
NSString * s = [NSString stringWithFormat:#"tel://%#",#"412-33-44-55"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:s]];
}