Skip to content

Commit 7ba3ded

Browse files
authored
Update API documentation for updates checked in background (#2842)
1 parent 7c460d7 commit 7ba3ded

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

Sparkle/SPUUpdater.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ SU_EXPORT NS_SWIFT_UI_ACTOR @interface SPUUpdater : NSObject
9292
- (BOOL)startUpdater:(NSError * __autoreleasing *)error;
9393

9494
/**
95-
Checks for updates, and displays progress while doing so if needed.
95+
Checks for new updates, and displays progress while doing so if needed.
9696
9797
This is meant for users initiating a new update check or checking the current update progress.
9898
@@ -109,25 +109,23 @@ SU_EXPORT NS_SWIFT_UI_ACTOR @interface SPUUpdater : NSObject
109109
- (void)checkForUpdates;
110110

111111
/**
112-
Checks for updates, but does not show any UI unless an update is found.
112+
Checks for new updates in the background.
113113
114-
You usually do not need to call this method directly. If `automaticallyChecksForUpdates` is @c YES,
115-
Sparkle calls this method automatically according to its update schedule using the `updateCheckInterval`
116-
and the `lastUpdateCheckDate`. Therefore, you should typically only consider calling this method directly if you
117-
opt out of automatic update checks. Calling this method when updating your own bundle is invalid if Sparkle is configured
118-
to ask the user's permission to check for updates automatically and `automaticallyChecksForUpdates` is `NO`.
119-
If you want to reset the updater's cycle after an updater setting change, see `resetUpdateCycle` or `resetUpdateCycleAfterShortDelay` instead.
114+
You usually should not call this method directly. By default Sparkle calls this method automatically
115+
on a scheduled basis if automatic update checks are enabled. This is done by checking the current state of
116+
`automaticallyChecksForUpdates`, `updateCheckInterval`, `lastUpdateCheckDate`, and
117+
`SUScheduledImpatientCheckInterval`.
120118
121-
This is meant for programmatically initiating a check for updates in the background without the user initiating it.
122-
This check will not show UI if no new updates are found.
119+
If you want to additionally force an update check on every app launch though, it's recommended to only call this method immediately after starting the updater,
120+
and only when automatic update checks are enabled (by checking `automaticallyChecksForUpdates` is `YES`). Calling this method at later points
121+
could interfere with Sparkle's scheduler in unexpected ways.
123122
124-
If a new update is found, the updater's user driver may handle showing it at an appropriate (but not necessarily immediate) time.
125-
If you want control over when and how a new update is shown, please see https://sparkle-project.org/documentation/gentle-reminders/
123+
If you want to reset the updater's cycle after an updater setting change, please use `resetUpdateCycle` or `resetUpdateCycleAfterShortDelay` instead.
126124
127-
Note if automated downloading/installing is turned on, either a new update may be downloaded in the background to be installed silently,
128-
or an already downloaded update may be shown.
125+
Updates that are found may not be presented immediately to the user, either due to automatic downloading/installing of updates being on or
126+
due to gentle reminders https://sparkle-project.org/documentation/gentle-reminders/ for example.
129127
130-
This will not find updates that the user has opted into skipping.
128+
Updates that have been skipped by the user will not be found.
131129
132130
This method does not do anything if there is a `sessionInProgress`.
133131

Sparkle/SPUUpdaterDelegate.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,16 +421,21 @@ NS_SWIFT_UI_ACTOR @protocol SPUUpdaterDelegate <NSObject>
421421
/**
422422
Called when an update is scheduled to be silently installed on quit after downloading the update automatically.
423423
424-
If the updater is given responsibility, it can later remind the user an update is available if they have not terminated the application for a long time.
424+
If you want to intercept this method without taking control of installing the update, return @c NO.
425+
This will let future update cycles to run and allow Sparkle to present the update to the user later if certain conditions are met.
426+
For example, critical updates will be presented to the user right away. Other updates may be presented later if the user hasn't terminated the application
427+
for a long time (defined by `SUScheduledImpatientCheckInterval`).
425428
426-
Also if the updater is given responsibility and the update item is marked critical, the new update will be presented to the user immediately after.
429+
If you want to take control of installing the update, return @c YES.
430+
This stalls the current update cycle and prevents future update cycles from running. When the opportunity arrives, you can invoke `immediateInstallHandler` to
431+
install the update and relaunch the application without any UI interaction shown.
427432
428-
Even if the @c immediateInstallHandler is not invoked, the installer will attempt to install the update on termination.
433+
In either case Sparkle will always attempt to install the update when the app terminates.
429434
430435
@param updater The updater instance.
431436
@param item The appcast item corresponding to the update that is proposed to be installed.
432-
@param immediateInstallHandler The install handler for the delegate to immediately install the update. No UI interaction will be shown and the application will be relaunched after installation. This handler can only be used if @c YES is returned and the delegate handles installing the update. For Sparkle 2.3 onwards, this handler can be invoked multiple times in case the application cancels the termination request.
433-
@return @c YES if the delegate will handle installing the update or @c NO if the updater should be given responsibility.
437+
@param immediateInstallHandler The install handler to immediately install the update and relaunch the application. This handler can only be used if @c YES is returned. For Sparkle 2.3 onwards, this handler can be invoked multiple times in case the application cancels the termination request.
438+
@return @c YES if you will handle installing the update using `immediateInstallHandler` or @c NO to allow Sparkle's update scheduler to continue running.
434439
*/
435440
- (BOOL)updater:(SPUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationBlock:(void (^)(void))immediateInstallHandler;
436441

0 commit comments

Comments
 (0)