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

DO u have andy demo code? I don't understand how to use this plugin thanks! #14

Closed
FunkSoul0518 opened this issue Mar 26, 2021 · 3 comments

Comments

@FunkSoul0518
Copy link

FunkSoul0518 commented Mar 26, 2021

DO u have any demo code? I don't understand how to use this plugin thanks!

@kolbasa
Copy link
Owner

kolbasa commented Mar 29, 2021

Sorry for the late reply. I overlooked the notification.

Yes, I admit the readme is a bit overkill.
Here is a simple example:


Create an empty cordova project:

cordova create Test com.example.id ApkUpdater
cd Test
cordova plugin add cordova-plugin-apkupdater
cordova platform add android
cordova run android --emulator

JS Code:
(In this example, the apk from my demo app is used.)

// This is optional, but is helpful to debug errors.
cordova.plugins.apkupdater.setObserver(
    {
        downloadProgress: console.log,
        exception: console.error
    }
);

await cordova.plugins.apkupdater.check('https://raw.githubusercontent.com/kolbasa/cordova-plugin-apkupdater-demo/master/update'); // you can ignore the result, if you already know, that you need this update
await cordova.plugins.apkupdater.download();
await cordova.plugins.apkupdater.install();

JS Code with callbacks:

// This is optional, but is helpful to debug errors.
cordova.plugins.apkupdater.setObserver(
    {
        downloadProgress: console.log,
        exception: console.error
    }
);

cordova.plugins.apkupdater.check(
    'https://raw.githubusercontent.com/kolbasa/cordova-plugin-apkupdater-demo/master/update,
    function (oVersion) { // you can ignore the result, if you already know, that you need this update
        cordova.plugins.apkupdater.download(
            function () { 
                cordova.plugins.apkupdater.install(console.log, console.error);
            },
            console.error
        );
    },
    console.error
);

EDIT: Fixed typo in last code block

@FunkSoul0518
Copy link
Author

FunkSoul0518 commented Mar 30, 2021

Thanks, i have one more question about check()
I have a file browser, and in this browser have version.xml and realease.apk .
Can i set the version.xml path in check() to detect update?

And I see the intro,do I have to unzip the apk?

@kolbasa
Copy link
Owner

kolbasa commented Mar 30, 2021

You need to compress the update with my script: create-manifest.js as described in the Readme.

Example:

node create-manifest.js 1.0.0 100k release.apk /path/to/your/desired/update-directory

The Plugin can't read your version.xml.

@kolbasa kolbasa closed this as completed Apr 12, 2021
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

2 participants