| 
									
										
										
										
											2015-08-19 18:55:11 +02:00
										 |  |  | # autoUpdater
 | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 20:11:59 +08:00
										 |  |  | This module provides an interface for the `Squirrel` auto-updater framework. | 
					
						
							| 
									
										
										
										
											2015-03-04 14:36:56 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 20:11:59 +08:00
										 |  |  | ## Platform notices
 | 
					
						
							| 
									
										
										
										
											2014-05-05 10:07:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-31 21:25:07 -05:00
										 |  |  | Though `autoUpdater` provides a uniform API for different platforms, there are | 
					
						
							| 
									
										
										
										
											2015-10-23 20:11:59 +08:00
										 |  |  | still some subtle differences on each platform. | 
					
						
							| 
									
										
										
										
											2014-05-05 10:07:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 20:11:59 +08:00
										 |  |  | ### OS X
 | 
					
						
							| 
									
										
										
										
											2014-07-25 09:14:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-03 15:30:54 +08:00
										 |  |  | On OS X, the `autoUpdater` module is built upon [Squirrel.Mac][squirrel-mac], | 
					
						
							|  |  |  | meaning you don't need any special setup to make it work. For server-side | 
					
						
							|  |  |  | requirements, you can read [Server Support][server-support]. | 
					
						
							| 
									
										
										
										
											2014-05-05 10:07:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 20:11:59 +08:00
										 |  |  | ### Windows
 | 
					
						
							| 
									
										
										
										
											2014-05-05 10:07:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-03 15:30:54 +08:00
										 |  |  | On Windows, you have to install your app into a user's machine before you can | 
					
						
							|  |  |  | use the auto-updater, so it is recommended to use | 
					
						
							|  |  |  | [grunt-electron-installer][installer] module to generate a Windows installer. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The installer generated with Squirrel will create a shortcut icon with an | 
					
						
							|  |  |  | [Application User Model ID][app-user-model-id] in the format of | 
					
						
							|  |  |  | `com.squirrel.PACKAGE_ID.YOUR_EXE_WITHOUT_DOT_EXE`, examples are | 
					
						
							|  |  |  | `com.squirrel.slack.Slack` and `com.squirrel.code.Code`. You have to use the | 
					
						
							|  |  |  | same ID for your app with `app.setAppUserModelId` API, otherwise Windows will | 
					
						
							|  |  |  | not be able to pin your app properly in task bar. | 
					
						
							| 
									
										
										
										
											2014-05-05 10:07:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-31 21:25:07 -05:00
										 |  |  | The server-side setup is also different from OS X. You can read the documents of | 
					
						
							| 
									
										
										
										
											2015-10-23 20:11:59 +08:00
										 |  |  | [Squirrel.Windows][squirrel-windows] to get more details. | 
					
						
							| 
									
										
										
										
											2014-05-05 10:07:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 20:11:59 +08:00
										 |  |  | ### Linux
 | 
					
						
							| 
									
										
										
										
											2014-05-05 10:07:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-14 01:02:30 +01:00
										 |  |  | There is no built-in support for auto-updater on Linux, so it is recommended to | 
					
						
							| 
									
										
										
										
											2015-10-23 20:11:59 +08:00
										 |  |  | use the distribution's package manager to update your app. | 
					
						
							| 
									
										
										
										
											2015-08-31 00:07:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-19 18:55:11 +02:00
										 |  |  | ## Events
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The `autoUpdater` object emits the following events: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### Event: 'error'
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Returns: | 
					
						
							| 
									
										
										
										
											2015-04-07 09:21:29 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 14:36:36 +08:00
										 |  |  | * `error` Error | 
					
						
							| 
									
										
										
										
											2015-04-07 09:21:29 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-23 17:57:42 +01:00
										 |  |  | Emitted when there is an error while updating. | 
					
						
							| 
									
										
										
										
											2015-04-07 09:21:29 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-19 18:55:11 +02:00
										 |  |  | ### Event: 'checking-for-update'
 | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-28 16:51:41 +01:00
										 |  |  | Emitted when checking if an update has started. | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-19 18:55:11 +02:00
										 |  |  | ### Event: 'update-available'
 | 
					
						
							| 
									
										
										
										
											2014-02-02 20:37:46 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-23 17:57:42 +01:00
										 |  |  | Emitted when there is an available update. The update is downloaded | 
					
						
							| 
									
										
										
										
											2014-02-02 20:37:46 +08:00
										 |  |  | automatically. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-19 18:55:11 +02:00
										 |  |  | ### Event: 'update-not-available'
 | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-02 20:37:46 +08:00
										 |  |  | Emitted when there is no available update. | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-19 18:55:11 +02:00
										 |  |  | ### Event: 'update-downloaded'
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Returns: | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | * `event` Event | 
					
						
							| 
									
										
										
										
											2014-02-02 20:37:46 +08:00
										 |  |  | * `releaseNotes` String | 
					
						
							|  |  |  | * `releaseName` String | 
					
						
							|  |  |  | * `releaseDate` Date | 
					
						
							| 
									
										
										
										
											2015-11-13 16:03:40 +08:00
										 |  |  | * `updateURL` String | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 15:50:55 +08:00
										 |  |  | Emitted when an update has been downloaded. | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 20:11:59 +08:00
										 |  |  | On Windows only `releaseName` is available. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-19 18:55:11 +02:00
										 |  |  | ## Methods
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The `autoUpdater` object has the following methods: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-13 16:03:40 +08:00
										 |  |  | ### `autoUpdater.setFeedURL(url)`
 | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | * `url` String | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 15:50:55 +08:00
										 |  |  | Sets the `url` and initialize the auto updater. The `url` cannot be changed | 
					
						
							| 
									
										
										
										
											2014-02-02 20:37:46 +08:00
										 |  |  | once it is set. | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-19 18:55:11 +02:00
										 |  |  | ### `autoUpdater.checkForUpdates()`
 | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-13 16:03:40 +08:00
										 |  |  | Asks the server whether there is an update. You must call `setFeedURL` before | 
					
						
							| 
									
										
										
										
											2014-02-02 20:37:46 +08:00
										 |  |  | using this API. | 
					
						
							| 
									
										
										
										
											2015-10-23 15:50:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-30 12:17:30 +01:00
										 |  |  | ### `autoUpdater.quitAndInstall()`
 | 
					
						
							| 
									
										
										
										
											2015-10-23 15:50:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-03 15:30:54 +08:00
										 |  |  | Restarts the app and installs the update after it has been downloaded. It | 
					
						
							|  |  |  | should only be called after `update-downloaded` has been emitted. | 
					
						
							| 
									
										
										
										
											2015-10-23 20:11:59 +08: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 | 
					
						
							| 
									
										
										
										
											2015-11-03 15:30:54 +08:00
										 |  |  | [app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx |