Skip to content

Commit

Permalink
Merge pull request #106 from amjaliks/features/showprompt
Browse files Browse the repository at this point in the history
Added call to show the prompt (the rating alert) explicitly
  • Loading branch information
arashpayan committed Apr 6, 2013
2 parents b938e6e + 881815a commit c2e9e5a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Appirater.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion Appirater.m
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c2e9e5a

Please sign in to comment.