electron/docs/api/auto-updater.md

94 lines
2.4 KiB
Markdown
Raw Normal View History

2015-08-19 16:55:11 +00:00
# autoUpdater
2013-08-14 22:43:35 +00:00
2015-10-23 12:11:59 +00:00
This module provides an interface for the `Squirrel` auto-updater framework.
2015-10-23 12:11:59 +00:00
## Platform notices
2015-10-23 12:11:59 +00:00
Though `autoUpdater` provides an uniform API for different platforms, there are
still some subtle differences on each platform.
2015-10-23 12:11:59 +00:00
### OS X
2015-10-23 12:11:59 +00:00
On OS X the `autoUpdater` module is built upon [Squirrel.Mac][squirrel-mac], you
don't need any special setup to make it work. For server-side requirements, you
can read [Server Support][server-support].
2015-10-23 12:11:59 +00:00
### Windows
2015-10-23 12:11:59 +00:00
On Windows you have to install your app into user's machine before you can use
the auto-updater, it is recommended to use [grunt-electron-installer][installer]
module to generate a Windows installer.
2015-10-23 12:11:59 +00:00
The server-side setup is also different from OS X, you can read the documents of
[Squirrel.Windows][squirrel-windows] to get more details.
2015-10-23 12:11:59 +00:00
### Linux
2015-10-23 12:11:59 +00:00
There is not built-in support for auto-updater on Linux, it is recommended to
use the distribution's package manager to update your app.
2015-08-19 16:55:11 +00:00
## Events
The `autoUpdater` object emits the following events:
### Event: 'error'
Returns:
2015-10-23 06:36:36 +00:00
* `error` Error
Emitted when there is an error while updating.
2015-08-19 16:55:11 +00:00
### Event: 'checking-for-update'
2013-08-14 22:43:35 +00:00
2015-07-28 15:51:41 +00:00
Emitted when checking if an update has started.
2013-08-14 22:43:35 +00:00
2015-08-19 16:55:11 +00:00
### Event: 'update-available'
Emitted when there is an available update. The update is downloaded
automatically.
2015-08-19 16:55:11 +00:00
### Event: 'update-not-available'
2013-08-14 22:43:35 +00:00
Emitted when there is no available update.
2013-08-14 22:43:35 +00:00
2015-08-19 16:55:11 +00:00
### Event: 'update-downloaded'
Returns:
2013-08-14 22:43:35 +00:00
* `event` Event
* `releaseNotes` String
* `releaseName` String
* `releaseDate` Date
* `updateUrl` String
2013-08-14 22:43:35 +00:00
2015-10-23 07:50:55 +00:00
Emitted when an update has been downloaded.
2013-08-14 22:43:35 +00:00
2015-10-23 12:11:59 +00:00
On Windows only `releaseName` is available.
2015-08-19 16:55:11 +00:00
## Methods
The `autoUpdater` object has the following methods:
### `autoUpdater.setFeedUrl(url)`
2013-08-14 22:43:35 +00:00
* `url` String
2015-10-23 07:50:55 +00:00
Sets the `url` and initialize the auto updater. The `url` cannot be changed
once it is set.
2013-08-14 22:43:35 +00:00
2015-08-19 16:55:11 +00:00
### `autoUpdater.checkForUpdates()`
2013-08-14 22:43:35 +00:00
2015-10-23 07:50:55 +00:00
Asks the server whether there is an update. You must call `setFeedUrl` before
using this API.
2015-10-23 07:50:55 +00:00
### `autoUpdater.quitAndUpdate()`
Restarts the app and install the update after it has been downloaded. It should
only be called after `update-downloaded` has been emitted.
2015-10-23 12:11:59 +00:00
[squirrel-mac]: https://github.com/Squirrel/Squirrel.Mac
[server-support]: https://github.com/Squirrel/Squirrel.Mac#server-support
[squirrel-windows]: https://github.com/Squirrel/Squirrel.Windows
[installer]: https://github.com/atom/grunt-electron-installer