Home / Programming / electron / electron auto-update system edit
Try Documentalist, my app that offers fast, offline access to 190+ programmer API docs.

High-level overview:
  • you specify a url to check for update
  • url needs to specify current version
  • need different urls for different OS (windows, mac etc.) and architecture (32-bit, 64-bit) combinations
When there's a version newer than the one in the url, the server returns json like:
{
  "url":"http://your-server.com/download/version/0.1.4/windows_32?filetype=zip",
}
There might be more fields but only url is necessary.
If there is no version newer than the one provided, return empty response with 204 (no content) status code.
This is bad because you need a server that returns different responses depending on the version provided in the url so you can't use a static server like s3.
A skeleton of the client code:
var electron = require("electron");
var app = electron.app;
var autoUpdater = electron.autoUpdater;
var ipcMain = electron.ipcMain;
var os = require("os");

// win32 for windows, darwin for mac
// https://nodejs.org/api/os.html#os_os_platform
var platform = os.platform() + '_' + os.arch();
var version = app.getVersion(); // comes from package.json

var updateIsReady = false;

ipcMain.on("my-program:install-update", function () {
    if (updateIsReady) {
        autoUpdater.quitAndInstall();
    }
    else {
        app.relaunch();
        app.quit();
    }
});

autoUpdater.on("update-downloaded", function () {
    updateIsReady = true;
    mainWindow.webContents.send("my-program:update-ready");
});

autoUpdater.setFeedURL('http://your-server.com/update/' + platform + '/' + version);

// check for updates after 2 minutes
setTimeout(autoUpdater.checkForUpdates, 2 * 60 * 1000);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:

Need fast, offline access to 190+ programmer API docs? Try my app Documentalist for Windows