Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem while creating an auto updater for my app #164

Open
AlexisL61 opened this issue Feb 22, 2019 · 0 comments
Open

Problem while creating an auto updater for my app #164

AlexisL61 opened this issue Feb 22, 2019 · 0 comments

Comments

@AlexisL61
Copy link

AlexisL61 commented Feb 22, 2019

I am an electron beginner and I want to implement autoUpdate to my app but I am stuck.

I have created a feedUrl using nuts and Heroku.

`const os = require('os'); const {app, autoUpdater, dialog} = require('electron'); const version = app.getVersion(); const platform
    = os.platform() + '_' + os.arch();  // usually returns darwin_64 const axios = require("axios")

    const updaterFeedURL = 'https://roblox-utility-autoupdate.herokuapp.com'+'/update/' + 'windows' + '/' + version;


function appUpdater(MainWindow) {

    autoUpdater.setFeedURL(updaterFeedURL);
    /* Log whats happening
    TODO send autoUpdater events to renderer so that we could console log it in developer tools
    You could alsoe use nslog or other logging to see what's happening */
    autoUpdater.on('error', err => MainWindow.webContents.executeJavaScript(`console.log("Error")
        console.log(`+err+`)`));
    autoUpdater.on('checking-for-update', () => MainWindow.webContents.executeJavaScript('console.log(`checking-for-update`)'));
    autoUpdater.on('update-available', () => MainWindow.webContents.executeJavaScript('console.log(`update-available`)'));
    autoUpdater.on('update-not-available', () => MainWindow.webContents.executeJavaScript('console.log(`update-not-available`)'));

    // Ask the user if update is available
    autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {

        MainWindow.webContents.executeJavaScript('console.log(`Update Downloaded`)')
        let message = app.getName() + ' ' + releaseName + ' is now available. It will be installed the next time you restart the application.';
        if (releaseNotes) {
            const splitNotes = releaseNotes.split(/[^\r]\n/);
            message += '\n\nRelease notes:\n';
            splitNotes.forEach(notes => {
                message += notes + '\n\n';
            });
        }
        // Ask user to update the app
        dialog.showMessageBox({
            type: 'question',
            buttons: ['Install and Relaunch', 'Later'],
            defaultId: 0,
            message: 'A new version of ' + app.getName() + ' has been downloaded',
            detail: message
        }, response => {
            if (response === 0) {
                setTimeout(() => autoUpdater.quitAndInstall(), 1);
            }
        });
    });
    // init for updates
    setInterval(function(){
    autoUpdater.checkForUpdates();
},10000)
}

exports = module.exports = {
    appUpdater
};`

Also, the feedUrl returns {"url":"http://roblox-utility-autoupdate.herokuapp.com/download/version/1.0.3/windows_32?filetype=zip","name":"1.0.3","notes":"Oh a new update ^^\nNew things \n","pub_date":"2019-02-22T14:02:26.000Z"} so i don't know why it deosn't update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant