Prevent iRate mechanism when handling local notifications

This commit is contained in:
Thomas Guillet 2016-12-08 10:47:10 +01:00 committed by Michael Kirk
parent 490795ea3d
commit 97500d55ec
5 changed files with 21 additions and 0 deletions

View File

@ -165,6 +165,7 @@ typedef NS_ENUM(NSUInteger, iRateErrorCode) {
- (void)promptIfAllCriteriaMet;
- (void)openRatingsPageInAppStore;
- (void)logEvent:(BOOL)deferPrompt;
- (void)preventPromptAtNextTest;
@end

View File

@ -128,6 +128,7 @@ static NSString *const iRateMacAppStoreURLFormat = @"macappstore://itunes.apple
@property (nonatomic, strong) id visibleAlert;
@property (nonatomic, assign) BOOL checkingForPrompt;
@property (nonatomic, assign) BOOL checkingForAppStoreID;
@property (nonatomic, assign) BOOL shouldPreventPromptAtNextTest;
@end
@ -224,6 +225,7 @@ static NSString *const iRateMacAppStoreURLFormat = @"macappstore://itunes.apple
self.remindPeriod = 1.0f;
self.verboseLogging = NO;
self.previewMode = NO;
self.shouldPreventPromptAtNextTest = NO;
#if DEBUG
@ -404,6 +406,10 @@ static NSString *const iRateMacAppStoreURLFormat = @"macappstore://itunes.apple
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)preventPromptAtNextTest {
self.shouldPreventPromptAtNextTest = YES;
}
- (void)incrementUseCount {
self.usesCount++;
}
@ -413,6 +419,14 @@ static NSString *const iRateMacAppStoreURLFormat = @"macappstore://itunes.apple
}
- (BOOL)shouldPromptForRating {
// Avoid potentially inconvenient prompt
if (self.shouldPreventPromptAtNextTest)
{
NSLog(@"iRate did not prompt for rating because it is potentially inconvenient");
self.shouldPreventPromptAtNextTest = NO;
return NO;
}
// preview mode?
if (self.previewMode) {
NSLog(@"iRate preview mode is enabled - make sure you disable this for release");

View File

@ -332,6 +332,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[AppStoreRating preventPromptAtNextTest];
[[PushManager sharedManager] application:application didReceiveLocalNotification:notification];
}

View File

@ -11,5 +11,6 @@
@interface AppStoreRating : NSObject
+ (void)setupRatingLibrary;
+ (void)preventPromptAtNextTest;
@end

View File

@ -25,4 +25,8 @@
rate.rateButtonLabel = NSLocalizedString(@"RATING_RATE", nil);
}
+ (void)preventPromptAtNextTest {
iRate *rate = [iRate sharedInstance];
[rate preventPromptAtNextTest];
}
@end