Skip to content
This repository

Add check for usage frequency #50

Merged
merged 2 commits into from over 1 year ago

2 participants

knokknok Nick Lockwood
knokknok

Will only prompt if used frequently enough (times per week, default is disabled)

Nick Lockwood nicklockwood merged commit 3315db7 into from October 06, 2012
Nick Lockwood nicklockwood closed this October 06, 2012
Nick Lockwood
Owner

Nice idea. I'll include it in the next release. Thanks.

Nick Lockwood
Owner

I've renamed the property to something a little clearer, but this feature is now included in version 1.5.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Sep 30, 2012
knokknok Update iRate/iRate.h 00d77ff
knokknok Add check for usage frequency f94600f
This page is out of date. Refresh to see the latest.
2  iRate/iRate.h
@@ -127,6 +127,7 @@ iRateErrorCode;
127 127
     NSUInteger _usesUntilPrompt;
128 128
     NSUInteger _eventsUntilPrompt;
129 129
     float _daysUntilPrompt;
  130
+    float _usageFrequencyForPrompt;
130 131
     float _remindPeriod;
131 132
     NSString *_messageTitle;
132 133
     NSString *_message;
@@ -165,6 +166,7 @@ iRateErrorCode;
165 166
 @property (nonatomic, assign) NSUInteger usesUntilPrompt;
166 167
 @property (nonatomic, assign) NSUInteger eventsUntilPrompt;
167 168
 @property (nonatomic, assign) float daysUntilPrompt;
  169
+@property (nonatomic, assign) float usageFrequencyForPrompt;
168 170
 @property (nonatomic, assign) float remindPeriod;
169 171
 
170 172
 //message text, you may wish to customise these, e.g. for localisation
13  iRate/iRate.m
@@ -80,6 +80,7 @@ @implementation iRate
80 80
 @synthesize applicationVersion = _applicationVersion;
81 81
 @synthesize applicationBundleID = _applicationBundleID;
82 82
 @synthesize daysUntilPrompt = _daysUntilPrompt;
  83
+@synthesize usageFrequencyForPrompt = _usageFrequencyForPrompt;
83 84
 @synthesize usesUntilPrompt = _usesUntilPrompt;
84 85
 @synthesize eventsUntilPrompt = _eventsUntilPrompt;
85 86
 @synthesize remindPeriod = _remindPeriod;
@@ -200,6 +201,7 @@ - (iRate *)init
200 201
         self.usesUntilPrompt = 10;
201 202
         self.eventsUntilPrompt = 10;
202 203
         self.daysUntilPrompt = 10.0f;
  204
+        self.usageFrequencyForPrompt = 0.0f;
203 205
         self.remindPeriod = 1.0f;
204 206
         self.verboseLogging = NO;
205 207
         self.previewMode = NO;
@@ -469,6 +471,17 @@ - (BOOL)shouldPromptForRating
469 471
         return NO;
470 472
     }
471 473
     
  474
+    //check if usage frequency is high enough
  475
+    else if ((float)self.usesCount < self.usageFrequencyForPrompt * [[NSDate date] timeIntervalSinceDate:self.firstUsed] / (7 * SECONDS_IN_A_DAY))
  476
+    {
  477
+        if (self.verboseLogging)
  478
+        {
  479
+            NSLog(@"iRate did not prompt for rating because the app has only been used %i times in %g weeks",
  480
+                  (int)self.usesCount, [[NSDate date] timeIntervalSinceDate:self.firstUsed] / (7 * SECONDS_IN_A_DAY));
  481
+        }
  482
+        return NO;
  483
+    }
  484
+
472 485
     //check if within the reminder period
473 486
     else if (self.lastReminded != nil && [[NSDate date] timeIntervalSinceDate:self.lastReminded] < self.remindPeriod * SECONDS_IN_A_DAY)
474 487
     {
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.