0
votes

electron builder version : 20.28.4

electron-updater version : 3.1.2

building for OSx, Windows & Ubuntu

I'm trying to create an electron app with an auto update mechanism. I'm facing an issue with the auto updater, especially for OSx. It works quite good on linux and windows (new version is downloaded and installed with autoUpdater.quitAndInstall(); or when the user quit the app). On OSx however, the new version gets downloaded, but is never installed.

The event fired when on update is downloaded is this one so i'm sure that the update is actually downloaded :

autoUpdater.on('update-downloaded', (ev, info) => {
    setImmediate(() => {
        let iChoice = dialog.showMessageBox({
            type: 'question',
            message: oTrad['on-update-downloaded'],
            buttons: [oTrad['quit_and_install'], oTrad['install_later']]
        });
        if (iChoice === 0) {
            setImmediate(() => {
                var browserWindows = BrowserWindow.getAllWindows();
                browserWindows.forEach(function(browserWindow) {
                    browserWindow.destroy();
                });
                autoUpdater.quitAndInstall();
            })
        }
    });
});

When the user click on "Quit and Install" which calls autoUpdater.quitAndInstall() the app does not actually close (still appear as open in the docks) and never actually re open itself. If I manually kill it and then launch it again -> the update-downloaded is fired again as if the update was never downloaded or installed in the first place. I'm quite lost since this mechanism is working perfectly on Linux & Windows.

UPDATE:

I found that my problem was related to the App Transport Security which was preventing the update on Mac, so I've added some configuration in my package.json to bypass that :

"extendInfo": {
        "NSAppTransportSecurity": {
          "NSAllowsArbitraryLoads": true
 }
}

My problem now is that the quitAndInstall() function is not working. The new version is downloaded AND installed only when I actually closed the app. If I call quitAndInstall, I'll have the following bug :

Error: No update available, can't quit and install Proxy server for native Squirell.Mac is closed

Thanks in advance

1

1 Answers

2
votes

I faced a similar issue for OSX and I solved it writing that. Before to quit I force to close all windows

if (iChoice === 0) {
 setImmediate(() => {
    app.removeAllListeners("window-all-closed")
    autoUpdater.quitAndInstall(false)
  })
}