From 32d4f249d4083b7019df2d6b6313a8042d2fa67b Mon Sep 17 00:00:00 2001 From: Andy Matuschak Date: Thu, 26 May 2011 18:52:24 -0700 Subject: [PATCH] Added a new Info.plist key: SUPromptUserOnFirstLaunch. Set this to YES to disable Sparkle's usual behavior of waiting 'till the second launch of an app to prompt for update permission. This is useful for apps which don't, under normal operations, get quit. Like a menu extra. --- SUConstants.h | 1 + SUConstants.m | 1 + SUUpdater.m | 11 ++++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/SUConstants.h b/SUConstants.h index 4a807d38..19191d0e 100644 --- a/SUConstants.h +++ b/SUConstants.h @@ -29,6 +29,7 @@ extern NSString *const SUEnableAutomaticChecksKeyOld; extern NSString *const SUEnableSystemProfilingKey; extern NSString *const SUSendProfileInfoKey; extern NSString *const SULastProfileSubmitDateKey; +extern NSString *const SUPromptUserOnFirstLaunchKey; extern NSString *const SUSparkleErrorDomain; // Appcast phase errors. diff --git a/SUConstants.m b/SUConstants.m index 5f06311f..536fc6c5 100644 --- a/SUConstants.m +++ b/SUConstants.m @@ -28,6 +28,7 @@ NSString *const SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks"; NSString *const SUEnableAutomaticChecksKeyOld = @"SUCheckAtStartup"; NSString *const SUSendProfileInfoKey = @"SUSendProfileInfo"; NSString *const SULastProfileSubmitDateKey = @"SULastProfileSubmissionDate"; +NSString *const SUPromptUserOnFirstLaunchKey = @"SUPromptUserOnFirstLaunch"; NSString *const SUSparkleErrorDomain = @"SUSparkleErrorDomain"; OSStatus SUAppcastParseError = 1000; diff --git a/SUUpdater.m b/SUUpdater.m index 93c71d00..ad2c722e 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -112,9 +112,14 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault if ([host objectForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]) [self setAutomaticallyChecksForUpdates:[host boolForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]]; // Now, we don't want to ask the user for permission to do a weird thing on the first launch. - // We wait until the second launch. - else if ([host boolForUserDefaultsKey:SUHasLaunchedBeforeKey] == NO) - [host setBool:YES forUserDefaultsKey:SUHasLaunchedBeforeKey]; + // We wait until the second launch, unless explicitly overridden via SUPromptUserOnFirstLaunchKey. + else if (![host objectForKey:SUPromptUserOnFirstLaunchKey]) + { + if ([host boolForUserDefaultsKey:SUHasLaunchedBeforeKey] == NO) + [host setBool:YES forUserDefaultsKey:SUHasLaunchedBeforeKey]; + else + shouldPrompt = YES; + } else shouldPrompt = YES; }