Skip to content

Instantly share code, notes, and snippets.

@AalokParikh
Created June 18, 2012 07:02
Show Gist options
  • Save AalokParikh/2947220 to your computer and use it in GitHub Desktop.
Save AalokParikh/2947220 to your computer and use it in GitHub Desktop.
Rate My App
#pragma mark - Rate My App
- (void)rateApp {
int launchCount = [[NSUserDefaults standardUserDefaults] integerForKey:@"launchCount"];
launchCount++;
[[NSUserDefaults standardUserDefaults] setInteger:launchCount forKey:@"launchCount"];
BOOL neverRate = [[NSUserDefaults standardUserDefaults] boolForKey:@"neverRate"];
if ((neverRate != YES) && (launchCount > 2)) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Please rate Hawaiian Names!"
message:@"You'd be the pineapple of my eye"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Rate now", @"Never ask again", @"Remind me later", nil];
alert.delegate = self;
[alert show];
[alert release];
}
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"neverRate"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/us/app/hawaiian-names/id473865842?ls=1&mt=8"]];
}
else if (buttonIndex == 1) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"neverRate"];
}
else if (buttonIndex == 2) {
// Do nothing
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment