Arun D
Arun D

Reputation: 2387

Electron auto-updater not relaunching the app

I am trying to set auto update in my electron mac app. I am using the following code:

const autoUpdater = electron.autoUpdater;

autoUpdater.setFeedURL('https://server_url?v=' + appVersion);

autoUpdater.checkForUpdates();

autoUpdater.on('update-downloaded', function(){

    autoUpdater.quitAndInstall();

});

But I think this statement autoUpdater.quitAndInstall() is not working. The app is not getting quit and relaunching. But if I manually quit the app and reopen, it opens the updated app. In the app I have a window which is not closable. Is that causing the issue here?

Upvotes: 4

Views: 1278

Answers (1)

Arun D
Arun D

Reputation: 2387

Yes. The non-closable window was causing the issue. I got the solution from electron documentation itself. I used the following code to solve the issue:

autoUpdater.on('update-downloaded', function(){

    mainWindow.setClosable(true);
    autoUpdater.quitAndInstall();

});

Upvotes: 4

Related Questions