Permalink
Browse files

Merge pull request #50 from knokknok/master

Add check for usage frequency
  • Loading branch information...
2 parents 5d959c2 + f94600f commit 3315db7d9a68f350db5174a5eb862cddc375323d @nicklockwood committed Oct 6, 2012
Showing with 15 additions and 0 deletions.
  1. +2 −0 iRate/iRate.h
  2. +13 −0 iRate/iRate.m
View
@@ -127,6 +127,7 @@ iRateErrorCode;
NSUInteger _usesUntilPrompt;
NSUInteger _eventsUntilPrompt;
float _daysUntilPrompt;
+ float _usageFrequencyForPrompt;
float _remindPeriod;
NSString *_messageTitle;
NSString *_message;
@@ -165,6 +166,7 @@ iRateErrorCode;
@property (nonatomic, assign) NSUInteger usesUntilPrompt;
@property (nonatomic, assign) NSUInteger eventsUntilPrompt;
@property (nonatomic, assign) float daysUntilPrompt;
+@property (nonatomic, assign) float usageFrequencyForPrompt;
@property (nonatomic, assign) float remindPeriod;
//message text, you may wish to customise these, e.g. for localisation
View
@@ -80,6 +80,7 @@ @implementation iRate
@synthesize applicationVersion = _applicationVersion;
@synthesize applicationBundleID = _applicationBundleID;
@synthesize daysUntilPrompt = _daysUntilPrompt;
+@synthesize usageFrequencyForPrompt = _usageFrequencyForPrompt;
@synthesize usesUntilPrompt = _usesUntilPrompt;
@synthesize eventsUntilPrompt = _eventsUntilPrompt;
@synthesize remindPeriod = _remindPeriod;
@@ -200,6 +201,7 @@ - (iRate *)init
self.usesUntilPrompt = 10;
self.eventsUntilPrompt = 10;
self.daysUntilPrompt = 10.0f;
+ self.usageFrequencyForPrompt = 0.0f;
self.remindPeriod = 1.0f;
self.verboseLogging = NO;
self.previewMode = NO;
@@ -469,6 +471,17 @@ - (BOOL)shouldPromptForRating
return NO;
}
+ //check if usage frequency is high enough
+ else if ((float)self.usesCount < self.usageFrequencyForPrompt * [[NSDate date] timeIntervalSinceDate:self.firstUsed] / (7 * SECONDS_IN_A_DAY))
+ {
+ if (self.verboseLogging)
+ {
+ NSLog(@"iRate did not prompt for rating because the app has only been used %i times in %g weeks",
+ (int)self.usesCount, [[NSDate date] timeIntervalSinceDate:self.firstUsed] / (7 * SECONDS_IN_A_DAY));
+ }
+ return NO;
+ }
+
//check if within the reminder period
else if (self.lastReminded != nil && [[NSDate date] timeIntervalSinceDate:self.lastReminded] < self.remindPeriod * SECONDS_IN_A_DAY)
{

0 comments on commit 3315db7

Please sign in to comment.