Save the NSDate into user defaults for first launch instead of the interval

This is more consistent with how the last update check logic works.
I changed the value of SUTimeIntervalAtFirstLaunchKey for backwards compatibility purposes.
This commit is contained in:
Zorg committed 2016-08-13 18:03:16 -04:00
1 parent 3d7f48e03d
commit b5ace2d037
2 files changed
+7 -7

No files matched your search

+6 -6
View File
@@ -250,11 +250,12 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
- (void)startUpdateCycle
{
BOOL shouldPrompt = NO;
NSNumber *timeIntervalAtFirstLaunch = [self.host objectForUserDefaultsKey:SUTimeIntervalAtFirstLaunchKey];
NSDate *firstLaunchDate = [self.host objectForUserDefaultsKey:SUTimeIntervalAtFirstLaunchKey];
NSDate *currentDate = [NSDate date];
// If the user has been asked about automatic checks, don't bother prompting
if ([self.host objectForUserDefaultsKey:SUEnableAutomaticChecksKey]) {
// When the user answers to the permission prompt, this will be set to either @YES or @NO instead of nil
if ([self.host objectForUserDefaultsKey:SUEnableAutomaticChecksKey] != nil) {
shouldPrompt = NO;
}
// If the developer wants to check for updates, we shouldn't bug the user about a prompt yet
@@ -272,8 +273,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
if ([self.host objectForKey:SUPromptUserOnFirstLaunchKey] != nil) {
shouldPrompt = YES;
} else if (timeIntervalAtFirstLaunch != nil) {
NSDate *firstLaunchDate = [NSDate dateWithTimeIntervalSinceReferenceDate:timeIntervalAtFirstLaunch.doubleValue];
} else if (firstLaunchDate != nil) {
NSTimeInterval intervalSinceFirstLaunch = [currentDate timeIntervalSinceDate:firstLaunchDate];
// We want to prompt if more than (or equal to) 'SUDefaultUpdatePermissionPromptInterval' seconds have passed since the first launch
// If the first launch time is after (or equal to) our current date, then something may have gone wrong in the system - prompt to be on the safe side
@@ -283,8 +283,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
}
}
if (timeIntervalAtFirstLaunch == nil) {
[self.host setObject:@([currentDate timeIntervalSinceReferenceDate]) forUserDefaultsKey:SUTimeIntervalAtFirstLaunchKey];
if (firstLaunchDate == nil) {
[self.host setObject:currentDate forUserDefaultsKey:SUTimeIntervalAtFirstLaunchKey];
}
if (shouldPrompt) {
+1 -1
View File
@@ -48,7 +48,7 @@ NSString *const SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks";
NSString *const SUSendProfileInfoKey = @"SUSendProfileInfo";
NSString *const SULastProfileSubmitDateKey = @"SULastProfileSubmissionDate";
NSString *const SUPromptUserOnFirstLaunchKey = @"SUPromptUserOnFirstLaunch";
NSString *const SUTimeIntervalAtFirstLaunchKey = @"SUTimeIntervalAtFirstLaunch";
NSString *const SUTimeIntervalAtFirstLaunchKey = @"SUTimeIntervalAtTheFirstLaunch";
NSString *const SUEnableJavaScriptKey = @"SUEnableJavaScript";
NSString *const SUFixedHTMLDisplaySizeKey = @"SUFixedHTMLDisplaySize";
NSString *const SUKeepDownloadOnFailedInstallKey = @"SUKeepDownloadOnFailedInstall";