Avoid 0xdead10cc crashes in iRate.

This commit is contained in:
Matthew Chen 2018-05-31 10:43:01 -04:00
parent fe12774406
commit f2fc2b9004
2 changed files with 13 additions and 6 deletions

View File

@ -162,7 +162,7 @@ typedef NS_ENUM(NSUInteger, iRateErrorCode) {
- (BOOL)shouldPromptForRating;
- (void)promptForRating;
- (void)promptIfNetworkAvailable;
- (void)promptIfAllCriteriaMet;
- (BOOL)promptIfAllCriteriaMet;
- (void)openRatingsPageInAppStore;
- (void)logEvent:(BOOL)deferPrompt;
- (void)preventPromptAtNextTest;

View File

@ -129,7 +129,7 @@ static NSString *const iRateMacAppStoreURLFormat = @"macappstore://itunes.apple
@property (nonatomic, assign) BOOL checkingForPrompt;
@property (nonatomic, assign) BOOL checkingForAppStoreID;
@property (nonatomic, assign) BOOL shouldPreventPromptAtNextTest;
@property (nonatomic) BOOL hasPromptedAtLaunch;
@property (nonatomic) BOOL hasQueuedSynchronize;
@end
@ -792,10 +792,15 @@ static NSString *const iRateMacAppStoreURLFormat = @"macappstore://itunes.apple
}
}
- (void)promptIfAllCriteriaMet {
- (BOOL)promptIfAllCriteriaMet {
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
return NO;
}
if ([self shouldPromptForRating]) {
[self promptIfNetworkAvailable];
return YES;
}
return NO;
}
- (BOOL)showRemindButton {
@ -972,9 +977,6 @@ static NSString *const iRateMacAppStoreURLFormat = @"macappstore://itunes.apple
- (void)applicationWillEnterForeground {
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
[self incrementUseCount];
if (self.promptAtLaunch) {
[self promptIfAllCriteriaMet];
}
}
}
@ -996,6 +998,11 @@ static NSString *const iRateMacAppStoreURLFormat = @"macappstore://itunes.apple
[[NSUserDefaults standardUserDefaults] synchronize];
self.hasQueuedSynchronize = NO;
}
if (self.promptAtLaunch && !self.hasPromptedAtLaunch) {
if ([self promptIfAllCriteriaMet]) {
self.hasPromptedAtLaunch = YES;
}
}
}
- (void)openRatingsPageInAppStore {