Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Electron auto-updater not relaunching the app

Tags:

macos

electron

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?

like image 949
Arun D Avatar asked Oct 27 '25 14:10

Arun D


1 Answers

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();

});
like image 103
Arun D Avatar answered Oct 29 '25 06:10

Arun D