diff --git a/Sparkle/SPUUpdater.m b/Sparkle/SPUUpdater.m index 2444315d..b0eb25fb 100644 --- a/Sparkle/SPUUpdater.m +++ b/Sparkle/SPUUpdater.m @@ -247,8 +247,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification - (void)startUpdateCycle { BOOL shouldPrompt = NO; - NSDate *firstLaunchDate = [self.host objectForUserDefaultsKey:SUTimeIntervalAtFirstLaunchKey]; - NSDate *currentDate = [NSDate date]; + BOOL hasLaunchedBefore = [self.host boolForUserDefaultsKey:SUHasLaunchedBeforeKey]; // If the user has been asked about automatic checks, don't bother prompting // When the user answers to the permission prompt, this will be set to either @YES or @NO instead of nil @@ -265,23 +264,12 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification } // Has the user been asked already? And don't ask if the host has a default value set in its Info.plist. else if ([self.host objectForKey:SUEnableAutomaticChecksKey] == nil) { - // Now, we don't want to ask the user for permission to do a weird thing right when they install the app - // We wait until another launch after a few hours have passed, unless explicitly overridden via SUPromptUserOnFirstLaunchKey. - - if ([self.host objectForKey:SUPromptUserOnFirstLaunchKey] != nil) { - shouldPrompt = YES; - } 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 - if (intervalSinceFirstLaunch >= SUDefaultUpdatePermissionPromptInterval || intervalSinceFirstLaunch <= 0) { - shouldPrompt = YES; - } - } + // We wait until the second launch of the updater for this host bundle, unless explicitly overridden via SUPromptUserOnFirstLaunchKey. + shouldPrompt = [self.host objectForKey:SUPromptUserOnFirstLaunchKey] || hasLaunchedBefore; } - if (firstLaunchDate == nil) { - [self.host setObject:currentDate forUserDefaultsKey:SUTimeIntervalAtFirstLaunchKey]; + if (!hasLaunchedBefore) { + [self.host setBool:YES forUserDefaultsKey:SUHasLaunchedBeforeKey]; } if (shouldPrompt) { diff --git a/Sparkle/SUConstants.h b/Sparkle/SUConstants.h index ec0bad29..8215f22d 100644 --- a/Sparkle/SUConstants.h +++ b/Sparkle/SUConstants.h @@ -34,6 +34,7 @@ extern NSString *const SUTechnicalErrorInformationKey; // ----------------------------------------------------------------------------- extern NSString *const SUFeedURLKey; +extern NSString *const SUHasLaunchedBeforeKey; extern NSString *const SUShowReleaseNotesKey; extern NSString *const SUSkippedVersionKey; extern NSString *const SUScheduledCheckIntervalKey; @@ -48,7 +49,6 @@ extern NSString *const SUEnableSystemProfilingKey; extern NSString *const SUSendProfileInfoKey; extern NSString *const SULastProfileSubmitDateKey; extern NSString *const SUPromptUserOnFirstLaunchKey; -extern NSString *const SUTimeIntervalAtFirstLaunchKey; extern NSString *const SUKeepDownloadOnFailedInstallKey; extern NSString *const SUDefaultsDomainKey; extern NSString *const SUEnableJavaScriptKey; diff --git a/Sparkle/SUConstants.m b/Sparkle/SUConstants.m index 229f1ef0..46633c81 100644 --- a/Sparkle/SUConstants.m +++ b/Sparkle/SUConstants.m @@ -21,9 +21,6 @@ const NSTimeInterval SUMinimumUpdateCheckInterval = DEBUG ? 60 : (60 * 60); const NSTimeInterval SUDefaultUpdateCheckInterval = DEBUG ? 60 : (60 * 60 * 24); -// Define the amount of time between Sparkle being started for the first time and before we can prompt the user for permission about checking for updates automatically -const NSTimeInterval SUDefaultUpdatePermissionPromptInterval = DEBUG ? (60 * 3) : (60 * 60 * 3); - // If the update has already been automatically downloaded, we normally don't want to bug the user about the update // However if the user has gone a very long time without quitting an application, we will bug them // This is the time interval for a "week"; it doesn't matter that this measure is imprecise. @@ -34,6 +31,7 @@ NSString *const SUBundleIdentifier = @SPARKLE_BUNDLE_IDENTIFIER; NSString *const SUTechnicalErrorInformationKey = @"SUTechnicalErrorInformation"; NSString *const SUFeedURLKey = @"SUFeedURL"; +NSString *const SUHasLaunchedBeforeKey = @"SUHasLaunchedBefore"; NSString *const SUShowReleaseNotesKey = @"SUShowReleaseNotes"; NSString *const SUSkippedVersionKey = @"SUSkippedVersion"; NSString *const SUScheduledCheckIntervalKey = @"SUScheduledCheckInterval"; @@ -48,7 +46,6 @@ NSString *const SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks"; NSString *const SUSendProfileInfoKey = @"SUSendProfileInfo"; NSString *const SULastProfileSubmitDateKey = @"SULastProfileSubmissionDate"; NSString *const SUPromptUserOnFirstLaunchKey = @"SUPromptUserOnFirstLaunch"; -NSString *const SUTimeIntervalAtFirstLaunchKey = @"SUTimeIntervalAtTheFirstLaunch"; NSString *const SUEnableJavaScriptKey = @"SUEnableJavaScript"; NSString *const SUFixedHTMLDisplaySizeKey = @"SUFixedHTMLDisplaySize"; NSString *const SUKeepDownloadOnFailedInstallKey = @"SUKeepDownloadOnFailedInstall";