Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor so there is a new rateApp method to explicitly rate the app.

  • Loading branch information...
commit c64066512dff7a37df3e572fc37bfff5d6a5af80 1 parent 216cb84
@mmorearty mmorearty authored
Showing with 25 additions and 8 deletions.
  1. +13 −0 Appirater.h
  2. +12 −8 Appirater.m
View
13 Appirater.h
@@ -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
View
20 Appirater.m
@@ -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];
@@ -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:
Please sign in to comment.
Something went wrong with that request. Please try again.