May 25, 2021 Electron
Enable automatic updates for applications.
Procedure: main
The autoUpdater module provides an interface for the Squirrel framework.
You can distribute applications by quickly launching a multi-platform publisher using one of the following projects:
While autoUpdater provides a unified API for different platforms, there are subtle differences on each platform.
On macOS, the autoUpdater module is based on Squirrel.Mac, which means you don't need any special settings to make it work. F or server-side requirements, you can read Server Support. N ote that Application Transport Security (ATS) applies to all requests that are part of the update process. Applications that need to disable ATS can add the NSAllowsArbitraryLoads key to the plist of their application.
Note: Your application must be signed to automatically update macOS. That's what Squirrel.Mac asks for.
On Windows, you must install your application on the user's machine before you can use autoUpdater, so it is recommended that you use the electronic-winstaller, electron-forge, or grunt-electron-installer packages to build the Windows installer.
When using electronic-winstaller or electronic forgery, make sure that you don't try to update the application the first time you run it (see also this question for more information). It is also recommended that you use Electronic Squirrel Launch to get desktop shortcuts to your application.
The installer generated using Squirrel will create a shortcut icon for the application user model ID in the format of com.squirrel.PACKAGE_ID.YOUR_EXE_WITHOUT_DOT_EXE, as shown in com.squirrel.slack.Slack and com.squirrel.code.Code. You must use the app.setAppUserModelId API to use the same ID for your app, otherwise Windows will not be able to boot your app correctly in the taskbar.
Unlike Squirrel.Mac, Windows can host updates on S3 or any other static file host. You can read the documentation for Squirrel.Windows for more details on how Squirrel.Windows works.
There is no built-in support for automatic updates on Linux, so it is recommended to update your application using the package manager for the distribution.
The autoUpdater object emits the following events:
Return:
Issued when an error occurs during an update.
Check to see if the update was issued when it was started.
Issued when an update is available. Updates will be downloaded automatically.
Issued when no updates are available.
Return:
Issued when the update is downloaded.
On Windows, only releaseName is available.
AutoUpdater objects have the following methods:
Set the url and initialize the automatic updater.
Back to String - the current update Feed URL.
Whether the request server has an update. Before you can use this API, you must call the setFeedURL.
Restart the application and download it after you install the update. It should only be called after update-downloaded.
Note: autoUpdater.quitAndInstall() will close all application windows before issuing a before-quit event after the app. This is different from the normal exit event sequence.