From b3f15ab78ab4428b4cc8991312b1136b705fcb58 Mon Sep 17 00:00:00 2001 From: Aleksejs Mjaliks Date: Sat, 16 Mar 2013 11:39:34 +0200 Subject: [PATCH 1/2] Added call to show the prompt (the rating alert) explicitly. In some cases you may want to show the prompt for rating explicitly regardless Appirater settings. --- Appirater.h | 9 +++++++++ Appirater.m | 13 ++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Appirater.h b/Appirater.h index 1c8d4375..eb76e1d6 100644 --- a/Appirater.h +++ b/Appirater.h @@ -142,6 +142,15 @@ 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 and the user 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 10708f2e..0df2a548 100644 --- a/Appirater.m +++ b/Appirater.m @@ -200,7 +200,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? @@ -337,6 +337,10 @@ - (void)incrementSignificantEventAndRate:(BOOL)canPromptForRating { } } +- (BOOL)userHasRatedCurrentVersion { + return [[NSUserDefaults standardUserDefaults] boolForKey:kAppiraterRatedCurrentVersion]; +} + + (void)appLaunched { [Appirater appLaunched:YES]; } @@ -376,6 +380,13 @@ + (void)userDidSignificantEvent:(BOOL)canPromptForRating { }); } ++ (void)showPrompt { + if ([[Appirater sharedInstance] connectedToNetwork] + && ![[Appirater sharedInstance] userHasRatedCurrentVersion]) { + [[Appirater sharedInstance] showRatingAlert]; + } +} + + (id)getRootViewController { UIWindow *window = [[UIApplication sharedApplication] keyWindow]; if (window.windowLevel != UIWindowLevelNormal) { From 881815a9b503513240772c049d2ed4694c364fce Mon Sep 17 00:00:00 2001 From: Aleksejs Mjaliks Date: Sat, 16 Mar 2013 12:25:54 +0200 Subject: [PATCH 2/2] Explicite prompt won't be showed, if user has declined to rate the app. --- Appirater.h | 3 ++- Appirater.m | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Appirater.h b/Appirater.h index eb76e1d6..572d740b 100644 --- a/Appirater.h +++ b/Appirater.h @@ -144,7 +144,8 @@ extern NSString *const kAppiraterReminderRequestDate; /* Tells Appirater to show the prompt (a rating alert). The prompt will be showed - if there is connection available and the user hasn't rated current version. + 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. diff --git a/Appirater.m b/Appirater.m index 0df2a548..31954ab3 100644 --- a/Appirater.m +++ b/Appirater.m @@ -337,6 +337,10 @@ - (void)incrementSignificantEventAndRate:(BOOL)canPromptForRating { } } +- (BOOL)userHasDeclinedToRate { + return [[NSUserDefaults standardUserDefaults] boolForKey:kAppiraterDeclinedToRate]; +} + - (BOOL)userHasRatedCurrentVersion { return [[NSUserDefaults standardUserDefaults] boolForKey:kAppiraterRatedCurrentVersion]; } @@ -382,6 +386,7 @@ + (void)userDidSignificantEvent:(BOOL)canPromptForRating { + (void)showPrompt { if ([[Appirater sharedInstance] connectedToNetwork] + && ![[Appirater sharedInstance] userHasDeclinedToRate] && ![[Appirater sharedInstance] userHasRatedCurrentVersion]) { [[Appirater sharedInstance] showRatingAlert]; }