diff --git a/Appirater.h b/Appirater.h index 97e4eedb..e3208abf 100644 --- a/Appirater.h +++ b/Appirater.h @@ -142,6 +142,16 @@ extern NSString *const kAppiraterReminderRequestDate; */ + (void)userDidSignificantEvent:(BOOL)canPromptForRating; +/* + Tells Appirater to show the prompt (a rating alert). The prompt will be showed + if there is connection available, the user hasn't declined to rate + or hasn't rated current version. + + You could call to show the prompt regardless Appirater settings, + e.g., in case of some special event in your app. + */ ++ (void)showPrompt; + /* 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 diff --git a/Appirater.m b/Appirater.m index 3cb59f7b..e524b9fe 100644 --- a/Appirater.m +++ b/Appirater.m @@ -204,7 +204,7 @@ - (BOOL)ratingConditionsHaveBeenMet { return NO; // has the user already rated the app? - if ([userDefaults boolForKey:kAppiraterRatedCurrentVersion]) + if ([self userHasRatedCurrentVersion]) return NO; // if the user wanted to be reminded later, has enough time passed? @@ -341,6 +341,14 @@ - (void)incrementSignificantEventAndRate:(BOOL)canPromptForRating { } } +- (BOOL)userHasDeclinedToRate { + return [[NSUserDefaults standardUserDefaults] boolForKey:kAppiraterDeclinedToRate]; +} + +- (BOOL)userHasRatedCurrentVersion { + return [[NSUserDefaults standardUserDefaults] boolForKey:kAppiraterRatedCurrentVersion]; +} + + (void)appLaunched { [Appirater appLaunched:YES]; } @@ -380,6 +388,14 @@ + (void)userDidSignificantEvent:(BOOL)canPromptForRating { }); } ++ (void)showPrompt { + if ([[Appirater sharedInstance] connectedToNetwork] + && ![[Appirater sharedInstance] userHasDeclinedToRate] + && ![[Appirater sharedInstance] userHasRatedCurrentVersion]) { + [[Appirater sharedInstance] showRatingAlert]; + } +} + + (id)getRootViewController { UIWindow *window = [[UIApplication sharedApplication] keyWindow]; if (window.windowLevel != UIWindowLevelNormal) {