Skip to content

Commit

Permalink
Refactor so there is a new rateApp method to explicitly rate the app.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmorearty committed Apr 20, 2011
1 parent 216cb84 commit c640665
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
13 changes: 13 additions & 0 deletions Appirater.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,17 @@ extern NSString *const kAppiraterDeclinedToRate;
*/
+ (void)userDidSignificantEvent:(BOOL)canPromptForRating;

/*
Tells Appirater to open the App Store page where the user can specify a
rating for the app. Also records the fact that this has happened, so the
user won't be prompted again to rate the app.
The only case where you should call this directly is if your app has an
explicit "Rate this app" command somewhere. In all other cases, don't worry
about calling this -- instead, just call the other functions listed above,
and let Appirater handle the bookkeeping of deciding when to ask the user
whether to rate the app.
*/
+ (void)rateApp;

@end
20 changes: 12 additions & 8 deletions Appirater.m
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,17 @@ + (void)userDidSignificantEvent:(BOOL)canPromptForRating {
[_canPromptForRating release];
}

+ (void)rateApp {
#if TARGET_IPHONE_SIMULATOR
NSLog(@"APPIRATER NOTE: iTunes App Store is not supported on the iOS simulator. Unable to open App Store page.");
#else
NSString *reviewURL = [templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%d", APPIRATER_APP_ID]];
[userDefaults setBool:YES forKey:kAppiraterRatedCurrentVersion];
[userDefaults synchronize];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:reviewURL]];
#endif
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];

Expand All @@ -347,15 +358,8 @@ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butto
}
case 1:
{
#if TARGET_IPHONE_SIMULATOR
NSLog(@"APPIRATER NOTE: iTunes App Store is not supported on the iOS simulator. Unable to open App Store page.");
#else
// they want to rate it
NSString *reviewURL = [templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%d", APPIRATER_APP_ID]];
[userDefaults setBool:YES forKey:kAppiraterRatedCurrentVersion];
[userDefaults synchronize];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:reviewURL]];
#endif
[Appirater rateApp];
break;
}
case 2:
Expand Down

0 comments on commit c640665

Please sign in to comment.