Created
June 18, 2012 07:02
-
-
Save AalokParikh/2947220 to your computer and use it in GitHub Desktop.
Rate My App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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