All Projects → kolbasa → cordova-plugin-apkupdater

kolbasa / cordova-plugin-apkupdater

Licence: MIT license
This plugin allows your Android app to download and install compressed updates without the Google Play Store.

Programming Languages

java
68154 projects - #9 most used programming language
javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to cordova-plugin-apkupdater

cordova-plugin-flurryanalytics
Adds support for all that Flurry Analytics flavored goodness to your Cordova based apps
Stars: ✭ 23 (-50%)
Mutual labels:  cordova, ionic, cordova-plugin
v-cupertino
A Vue 3 Wrapper for Cupertino Pane Library
Stars: ✭ 17 (-63.04%)
Mutual labels:  cordova, ionic, capacitor
Cordova Background Geolocation Lt
The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
Stars: ✭ 600 (+1204.35%)
Mutual labels:  cordova, ionic, background
ionic-vue-mobile-template-03
Hybrid app template built with vue, ionic and capacitor.
Stars: ✭ 62 (+34.78%)
Mutual labels:  cordova, ionic, capacitor
capacitor-rate-app
Let users rate your app using native review app dialog for both Android and iOS.
Stars: ✭ 88 (+91.3%)
Mutual labels:  cordova, ionic, capacitor
scanbot-sdk-example-ionic
Scanbot scanner SDK example app for Ionic with Cordova.
Stars: ✭ 24 (-47.83%)
Mutual labels:  cordova, ionic, cordova-plugin
Cordova Admob Pro
🔥 Cordova Plugin for Google AdMob, DFP, ADX. Easy monetization using mobile Ad, with single line of JavaScript. Compatible with Cordova CLI, Inoic, PhoneGap Build, etc.
Stars: ✭ 690 (+1400%)
Mutual labels:  cordova, ionic, cordova-plugin
Capacitor
Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
Stars: ✭ 6,598 (+14243.48%)
Mutual labels:  cordova, ionic, capacitor
Cordova Plugin Fingerprint Aio
👆 📱 Cordova Plugin for fingerprint sensors (and FaceID) with Android and iOS support
Stars: ✭ 236 (+413.04%)
Mutual labels:  cordova, ionic, cordova-plugin
Unityionicintegration
A guide to integrating Unity 3D content into an Ionic app and sending messages between them (for Android & iOS)(tested with Vuforia plugin)
Stars: ✭ 94 (+104.35%)
Mutual labels:  cordova, ionic, cordova-plugin
ionic-native-sms-retriever-plugin-master
Cross-platform plugin for Cordova / PhoneGap to Retrieve SMS. Available for Android.
Stars: ✭ 16 (-65.22%)
Mutual labels:  cordova, ionic, cordova-plugin
ionic-hockeyapp
Need HockeyApp in your Ionic application, add this package!
Stars: ✭ 19 (-58.7%)
Mutual labels:  cordova, ionic, cordova-plugin
cordova-plugin-today-widget
Add a today widget app extension target to your cordova project.
Stars: ✭ 51 (+10.87%)
Mutual labels:  cordova, ionic, cordova-plugin
Ionic Native
Native features for mobile apps built with Cordova/PhoneGap and open web technologies. Complete with TypeScript support.
Stars: ✭ 2,129 (+4528.26%)
Mutual labels:  cordova, ionic, cordova-plugin
Apkupdater
APKUpdater is an open source tool that simplifies the process of finding updates for your installed apps.
Stars: ✭ 1,028 (+2134.78%)
Mutual labels:  updater, installer, apk
Ionic4
This repo contains example code for ionic4. Get Step by Step tutorial of this repo examples using https://ampersandacademy.com/tutorials/ionic-framework-4
Stars: ✭ 37 (-19.57%)
Mutual labels:  cordova, ionic, cordova-plugin
cordova-plugin-android-window-background
Simple Cordova plugin to set Android window background on start-up 🎨 🍭
Stars: ✭ 15 (-67.39%)
Mutual labels:  cordova, ionic, cordova-plugin
example-cordova-code-push-plugin
Ionic + Cordova Code Push Plugin Example
Stars: ✭ 45 (-2.17%)
Mutual labels:  cordova, ionic, cordova-plugin
Port-Able-Suite
🌐 Manager for portable applications
Stars: ✭ 35 (-23.91%)
Mutual labels:  downloader, updater
APK-Downloader
Download latest version of android apps and games from Google Play.
Stars: ✭ 54 (+17.39%)
Mutual labels:  apk, play-store

Cordova Apk Updater Plugin · License npm npm

Installation dialog

This plugin enables you to update your Android app completely without the Google Play Store.

👉 DEMO APP 👈



Plugin requirements

  • Android: 5+
  • cordova: 10.0.0+
  • cordova-android: 9.0.0+

Installation

Cordova

cordova plugin add cordova-plugin-apkupdater

Ionic + Cordova

ionic cordova plugin add cordova-androidx-build
ionic cordova plugin add cordova-plugin-apkupdater

Capacitor

npm install cordova-plugin-apkupdater

Basic example

Ionic 2+ with Typescript

Here is the simplest example: downloading and then installing the APK:

Sample Implementation:

import ApkUpdater from 'cordova-plugin-apkupdater';

export class HomePage {

    // .
    // .
    // .

    async update() {
        await ApkUpdater.download(
            'https://your-update-server.com/update.apk',
            {
                onDownloadProgress: console.log
            }
        );
        await ApkUpdater.install();
    }

}

(Complete code sample)

Cordova

The same example with callbacks:

ApkUpdater.download(
    'https://your-update-server.com/update.apk',
    {
        onDownloadProgress: console.log
    },
    function () {
        ApkUpdater.install(console.log, console.error);
    },
    console.error
);

API

The JavaScript API supports promises and callbacks for all methods.
The callback functions occupy the last two parameters.

// promise
await ApkUpdater.download('https://your-update-server.com/update.apk', options);

// alternative with callbacks
ApkUpdater.download('https://your-update-server.com/update.apk', options, success, failure);

On this page I only show Promise examples for simplicity.

In case of a failure you get an error object with two attributes: message and stack.

This example...

try {
    await ApkUpdater.download('https://wrong-url.com/update.apk');
} catch (e) {
    console.error(e.message + '\n' + e.stack);
}

... leads to the following output:

Download failed: Unable to resolve host "wrong-url.com": No address associated with hostname
de.kolbasa.apkupdater.exceptions.DownloadFailedException
  at de.kolbasa.apkupdater.downloader.FileDownloader.download(FileDownloader.java:111)
  at de.kolbasa.apkupdater.update.UpdateManager.downloadFile(UpdateManager.java:77)
  at de.kolbasa.apkupdater.update.UpdateManager.download(UpdateManager.java:133)
  at de.kolbasa.apkupdater.ApkUpdater.download(ApkUpdater.java:85)

download()

await ApkUpdater.download('https://your-update-server.com/update.apk', options);

You can also pass a zip file here. The zip file can even be encrypted with a password.
However, you should make sure that the archive contains only the APK file at root level, nothing else.
If you want to automate this, then you can also use my script.

Configuration (optional):

const options = {
    zipPassword: 'aDzEsCceP3BPO5jy', // If an encrypted zip file is used.
    basicAuth: { // Basic access authentication
        user: 'username',
        password: 'JtE+es2GcHrjTAEU'
    },
    onDownloadProgress: function (e) {
        console.log(
            'Downloading: ' + e.progress + '%',
            '(' + e.bytesWritten + '/' + e.bytes + ')'
        );
    },
    onUnzipProgress: function (e) {
        console.log(
            'Unzipping: ' + e.progress + '%',
            '(' + e.bytesWritten + '/' + e.bytes + ')'
        );
    }
}

If the download is successful, you will receive detailed information about the update file.

{
  "name": "update.apk",
  "path": "/data/user/0/de.kolbasa.apkupdater.demo/files/update",
  "size": 1982411,
  "app": {
    "name": "Apk Updater Demo",
    "package": "de.kolbasa.apkupdater.demo",
    "version": {
      "code": 10001,
      "name": "1.0.1"
    }
  }
}

stop()

Stops the download.

await ApkUpdater.stop();

getInstalledVersion()

Provides detailed information about the currently installed app version.

await ApkUpdater.getInstalledVersion();

Example output:

const result = {
    "name": "Apk Updater Demo",
    "package": "de.kolbasa.apkupdater.demo",
    "firstInstallTime": 1625415754434, // Unix timestamp
    "version": {
        "code": 10000,
        "name": "1.0.0"
    }
}

getDownloadedUpdate()

The downloaded update remains saved even after an app restart and can be queried as follows:

await ApkUpdater.getDownloadedUpdate();

The result uses the same format as the output from the download() method.


reset()

The reset method deletes all downloaded files.

It is mostly useful only for debugging purposes. The user himself has no access to the files.
The plugin deletes old updates automatically.

await ApkUpdater.reset();

install()

As soon as the download has been completed, you can use this method to ask the user to install the APK.

await ApkUpdater.install();

When the method is invoked for the first time, the user is asked to enable a setting for installing third-party applications (video).

You may want to ask the user for this permission before installing the first update.
The following two methods canRequestPackageInstalls and openInstallSetting are intended for this purpose.

canRequestPackageInstalls()

Queries whether the installation of updates has been allowed.

await ApkUpdater.canRequestPackageInstalls(); // -> true, false

openInstallSetting()

Opens the settings page (video).

await ApkUpdater.openInstallSetting(); // -> true, false

rootInstall()

If you have a rooted device, then you can even set up unattended app update installations (video).
If you want to test this on an emulator, I can recommend the following script: rootAVD

await ApkUpdater.rootInstall();

isDeviceRooted()

await ApkUpdater.isDeviceRooted(); // -> true, false

requestRootAccess()

Requests root access (video).

await ApkUpdater.requestRootAccess(); // -> true, false

ownerInstall()

Unattended updates can also be used by apps that are registered as device owners (video).

await ApkUpdater.ownerInstall();

Unlike root access, this can be easily set up on any Android device. Instructions can be found here.

isDeviceOwner()

await ApkUpdater.isDeviceOwner(); // -> true, false

Update versioning

The plugin itself does not make a version comparison.
You need to find a solution that best suits your use case.

If you always have Wi-Fi, you could download the entire apk at regular intervals and check whether the version has changed.
If you use mobile data, which is usually limited, then you should have a different strategy.
You may already have a remote API and can request the latest version there.

In my case, I simply place a small update.json file next to the update, which stores the latest version number.
I then simply compare this version with the internal one, which I request with the getInstalledVersion method.

This is also the case with the demo linked above.
Here is my script that I use to create the compressed update and info file.

Sample Implementation:

import ApkUpdater from 'cordova-plugin-apkupdater';

export class HomePage {

    // .
    // .
    // .

    remote = 'https://your-update-server.com'

    async update() {
        const manifest = await this.http.get<Update>(this.remote + '/update.json').toPromise();

        const remoteVersion = manifest.app.version.code;
        const installedVersion = (await ApkUpdater.getInstalledVersion()).version.code;

        if (remoteVersion > installedVersion) {
            await ApkUpdater.download(this.remote + '/update.apk');
            await ApkUpdater.install();
        }
    }
}

(Complete code sample)


License

MIT License

Copyright (c) 2021 Michael Jedich

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].