Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/nicklockwood/iRate
Browse files Browse the repository at this point in the history
Conflicts:
	iRate/iRate.bundle/es.lproj/Localizable.strings
  • Loading branch information
nicklockwood committed Oct 6, 2012
2 parents 9cd66e5 + 3315db7 commit 5eef4e3
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Examples/Mac Demo/iRateMac-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
<string>com.charcoaldesign.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
1 change: 1 addition & 0 deletions Examples/Mac Demo/iRateMac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = iRateMac_Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
INFOPLIST_FILE = "iRateMac-Info.plist";
INSTALL_PATH = "$(HOME)/Applications";
PRODUCT_NAME = iRateMac;
Expand Down
2 changes: 1 addition & 1 deletion Examples/Mac Demo/iRateMacAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ + (void)initialize
//but we want to test with an app that's actually on the store
[iRate sharedInstance].applicationBundleID = @"com.charcoaldesign.RainbowBlocksLite";
[iRate sharedInstance].onlyPromptIfLatestVersion = NO;

//enable preview mode
[iRate sharedInstance].previewMode = YES;
}
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ This is the minimum number of times the user must launch the app before they are

For some apps, launches are not a good metric for usage. For example the app might be a daemon that runs constantly, or a game where the user can't write an informed review until they've reached a particular level. In this case you can manually log significant events and have the prompt appear after a predetermined number of these events. Like the usesUntilPrompt setting, the prompt will appear only after the specified number of days AND events, however once the day threshold is reached, the prompt will appear if EITHER the event threshold OR uses threshold is reached. This defaults to 10 events.

@property (nonatomic, assign) float usesPerWeekForPrompt;

If you are less concerned with the total number of times the app is used, but would prefer to use the *frequency* of times the app is used, you can use the `usesPerWeekForPrompt` property to set a minimum threshold for the number of times the user must launch the app per week (on average) for the prompt to be shown. Note that this is the average since the app was installed, so if the user goes for a long period without running the app, it may throw off the average. The default value is zero.

@property (nonatomic, assign) float remindPeriod;

How long the app should wait before reminding a user to rate after they select the "remind me later" option (measured in days). A value of zero means the app will remind the user next launch. Note that this value supersedes the other criteria, so the app won't prompt for a rating during the reminder period, even if a new version is released in the meantime. This defaults to 1 day.
Expand Down Expand Up @@ -161,6 +165,10 @@ The number of times the current version of the app has been used (launched).

The number of significant application events that have been recorded since the current version was installed. This is incremented by the logEvent method, but can also be manipulated directly. Check out the *Events Demo* to see how this os used.

@property (nonatomic, readonly) float usesPerWeek;

The average number of times per week that the current version of the app has been used (launched).

@property (nonatomic, assign) BOOL declinedThisVersion;

This flag indicates whether the user has declined to rate the current version (YES) or not (NO).
Expand Down
1 change: 1 addition & 0 deletions RELEASE NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Version 1.5.4

- Added new localisation system (see README for details)
- Added usesPerWeekForPrompt setting
- Fixed deprecation warning in iOS 6
- Improved Spanish translation
- Improved German translation
Expand Down
5 changes: 4 additions & 1 deletion iRate/iRate.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extern NSUInteger const iRateAppStoreGameGenreID;
extern NSString *const iRateErrorDomain;


//localisation string file keys
//localisation string keys
static NSString *const iRateMessageTitleKey = @"iRateMessageTitle";
static NSString *const iRateAppMessageKey = @"iRateAppMessage";
static NSString *const iRateGameMessageKey = @"iRateGameMessage";
Expand Down Expand Up @@ -135,6 +135,7 @@ iRateErrorCode;
NSUInteger _usesUntilPrompt;
NSUInteger _eventsUntilPrompt;
float _daysUntilPrompt;
float _usesPerWeekForPrompt;
float _remindPeriod;
NSString *_messageTitle;
NSString *_message;
Expand Down Expand Up @@ -173,6 +174,7 @@ iRateErrorCode;
@property (nonatomic, assign) NSUInteger usesUntilPrompt;
@property (nonatomic, assign) NSUInteger eventsUntilPrompt;
@property (nonatomic, assign) float daysUntilPrompt;
@property (nonatomic, assign) float usesPerWeekForPrompt;
@property (nonatomic, assign) float remindPeriod;

//message text, you may wish to customise these
Expand All @@ -197,6 +199,7 @@ iRateErrorCode;
@property (nonatomic, strong) NSDate *lastReminded;
@property (nonatomic, assign) NSUInteger usesCount;
@property (nonatomic, assign) NSUInteger eventCount;
@property (nonatomic, readonly) float usesPerWeek;
@property (nonatomic, assign) BOOL declinedThisVersion;
@property (nonatomic, readonly) BOOL declinedAnyVersion;
@property (nonatomic, assign) BOOL ratedThisVersion;
Expand Down
25 changes: 21 additions & 4 deletions iRate/iRate.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@


#define SECONDS_IN_A_DAY 86400.0
#define SECONDS_IN_A_WEEK 604800.0
#define MAC_APP_STORE_REFRESH_DELAY 5.0
#define REQUEST_TIMEOUT 60.0

Expand All @@ -79,6 +80,7 @@ @implementation iRate
@synthesize applicationVersion = _applicationVersion;
@synthesize applicationBundleID = _applicationBundleID;
@synthesize daysUntilPrompt = _daysUntilPrompt;
@synthesize usesPerWeekForPrompt = _usesPerWeekForPrompt;
@synthesize usesUntilPrompt = _usesUntilPrompt;
@synthesize eventsUntilPrompt = _eventsUntilPrompt;
@synthesize remindPeriod = _remindPeriod;
Expand Down Expand Up @@ -183,6 +185,7 @@ - (iRate *)init
self.usesUntilPrompt = 10;
self.eventsUntilPrompt = 10;
self.daysUntilPrompt = 10.0f;
self.usesPerWeekForPrompt = 0.0f;
self.remindPeriod = 1.0f;
self.verboseLogging = NO;
self.previewMode = NO;
Expand Down Expand Up @@ -305,6 +308,11 @@ - (void)setEventCount:(NSUInteger)count
[[NSUserDefaults standardUserDefaults] synchronize];
}

- (float)usesPerWeek
{
return (float)self.usesCount / ([[NSDate date] timeIntervalSinceDate:self.firstUsed] / SECONDS_IN_A_WEEK);
}

- (BOOL)declinedThisVersion
{
return [[[NSUserDefaults standardUserDefaults] objectForKey:iRateDeclinedVersionKey] isEqualToString:self.applicationVersion];
Expand Down Expand Up @@ -411,7 +419,7 @@ - (BOOL)shouldPromptForRating
}

//check for first launch
else if (self.daysUntilPrompt > 0.0f && self.firstUsed == nil)
else if ((self.daysUntilPrompt > 0.0f || self.usesPerWeekForPrompt) && self.firstUsed == nil)
{
if (self.verboseLogging)
{
Expand All @@ -425,7 +433,7 @@ - (BOOL)shouldPromptForRating
{
if (self.verboseLogging)
{
NSLog(@"iRate did not prompt for rating because the last prompt was less than %g days ago", self.daysUntilPrompt);
NSLog(@"iRate did not prompt for rating because the app was first used less than %g days ago", self.daysUntilPrompt);
}
return NO;
}
Expand All @@ -435,12 +443,21 @@ - (BOOL)shouldPromptForRating
{
if (self.verboseLogging)
{
NSLog(@"iRate did not prompt for rating because the app has only been used %i/%i times and only %i/%i events have been logged",
(int)self.usesCount, (int)self.usesUntilPrompt, (int)self.eventCount, (int)self.eventsUntilPrompt);
NSLog(@"iRate did not prompt for rating because the app has only been used %i times and only %i events have been logged", (int)self.usesCount, (int)self.eventCount);
}
return NO;
}

//check if usage frequency is high enough
else if (self.usesPerWeek < self.usesPerWeekForPrompt)
{
if (self.verboseLogging)
{
NSLog(@"iRate did not prompt for rating because the app has only been used %g times per week on average since it was installed", self.usesPerWeek);
}
return NO;
}

//check if within the reminder period
else if (self.lastReminded != nil && [[NSDate date] timeIntervalSinceDate:self.lastReminded] < self.remindPeriod * SECONDS_IN_A_DAY)
{
Expand Down

0 comments on commit 5eef4e3

Please sign in to comment.