Skip to content

Commit

Permalink
* Fixed off by one problem
Browse files Browse the repository at this point in the history
* setDebug only shows debug
* setForceRatingConditionsMet which triggers the rating alert all the time
* Added new method reset : Resets database, useful for testing
  • Loading branch information
Zakay committed Apr 10, 2013
1 parent c2e9e5a commit ef4ff66
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
12 changes: 11 additions & 1 deletion Appirater.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,21 @@ extern NSString *const kAppiraterReminderRequestDate;
*/
+ (void) setTimeBeforeReminding:(double)value;

/*
'YES' will show the Appirater logs. Useful for debugging.
*/
+ (void) setDebug:(BOOL)debug;

/*
'YES' will show the Appirater alert everytime. Useful for testing how your message
looks and making sure the link to your app's review page works.
*/
+ (void) setDebug:(BOOL)debug;
+ (void)setForceRatingConditionsMet:(BOOL)forceRatingConditionsMet;

/*
Tells Appirater to reset all counters
*/
+ (void)reset;

/*
Set the delegate if you want to know when Appirater does something
Expand Down
26 changes: 23 additions & 3 deletions Appirater.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
static NSInteger _significantEventsUntilPrompt = -1;
static double _timeBeforeReminding = 1;
static BOOL _debug = NO;
static BOOL _forceRatingConditionsMet = NO;
static id<AppiraterDelegate> _delegate;
static BOOL _usesAnimation = TRUE;
static BOOL _openInAppStore = NO;
Expand Down Expand Up @@ -100,6 +101,25 @@ + (void) setTimeBeforeReminding:(double)value {
+ (void) setDebug:(BOOL)debug {
_debug = debug;
}

+ (void) setForceRatingConditionsMet:(BOOL)forceRatingConditionsMet {
_forceRatingConditionsMet = forceRatingConditionsMet;
}

+ (void) reset {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];

[userDefaults removeObjectForKey:kAppiraterCurrentVersion];
[userDefaults removeObjectForKey:kAppiraterFirstUseDate];
[userDefaults removeObjectForKey:kAppiraterUseCount];
[userDefaults removeObjectForKey:kAppiraterSignificantEventCount];
[userDefaults removeObjectForKey:kAppiraterRatedCurrentVersion];
[userDefaults removeObjectForKey:kAppiraterDeclinedToRate];
[userDefaults removeObjectForKey:kAppiraterReminderRequestDate];

[userDefaults synchronize];
}

+ (void)setDelegate:(id<AppiraterDelegate>)delegate{
_delegate = delegate;
}
Expand Down Expand Up @@ -178,7 +198,7 @@ - (void)showRatingAlert {
}

- (BOOL)ratingConditionsHaveBeenMet {
if (_debug)
if (_forceRatingConditionsMet)
return YES;

NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
Expand All @@ -191,12 +211,12 @@ - (BOOL)ratingConditionsHaveBeenMet {

// check if the app has been used enough
int useCount = [userDefaults integerForKey:kAppiraterUseCount];
if (useCount <= _usesUntilPrompt)
if (useCount < _usesUntilPrompt)
return NO;

// check if the user has done enough significant events
int sigEventCount = [userDefaults integerForKey:kAppiraterSignificantEventCount];
if (sigEventCount <= _significantEventsUntilPrompt)
if (sigEventCount < _significantEventsUntilPrompt)
return NO;

// has the user previously declined to rate this version of the app?
Expand Down

0 comments on commit ef4ff66

Please sign in to comment.