{"id":24859524,"url":"https://github.com/kolbasa/cordova-plugin-apkupdater","last_synced_at":"2025-04-09T09:06:03.304Z","repository":{"id":37246785,"uuid":"200521153","full_name":"kolbasa/cordova-plugin-apkupdater","owner":"kolbasa","description":"This plugin allows your Android app to download and install compressed updates without the Google Play Store.","archived":false,"fork":false,"pushed_at":"2024-06-18T11:39:30.000Z","size":217,"stargazers_count":105,"open_issues_count":0,"forks_count":23,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T06:07:45.597Z","etag":null,"topics":["android","apk","automatic","background","capacitor","cordova","cordova-plugin","downloader","google","installer","ionic","play-store","updater","xapk"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kolbasa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-04T17:18:21.000Z","updated_at":"2025-03-11T05:34:14.000Z","dependencies_parsed_at":"2024-06-18T13:11:41.868Z","dependency_job_id":null,"html_url":"https://github.com/kolbasa/cordova-plugin-apkupdater","commit_stats":{"total_commits":229,"total_committers":4,"mean_commits":57.25,"dds":"0.35371179039301315","last_synced_commit":"feeb7f1b7357dbc2d35d8e2d016911c30e3ce832"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolbasa%2Fcordova-plugin-apkupdater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolbasa%2Fcordova-plugin-apkupdater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolbasa%2Fcordova-plugin-apkupdater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolbasa%2Fcordova-plugin-apkupdater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kolbasa","download_url":"https://codeload.github.com/kolbasa/cordova-plugin-apkupdater/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008629,"owners_count":21032556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","apk","automatic","background","capacitor","cordova","cordova-plugin","downloader","google","installer","ionic","play-store","updater","xapk"],"created_at":"2025-01-31T20:31:06.331Z","updated_at":"2025-04-09T09:06:03.280Z","avatar_url":"https://github.com/kolbasa.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Cordova Apk Updater Plugin \u0026middot; [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/kolbasa/cordova-plugin-apkupdater/blob/master/LICENSE) [![npm](https://img.shields.io/npm/v/cordova-plugin-apkupdater.svg)](https://www.npmjs.com/package/cordova-plugin-apkupdater) [![npm](https://img.shields.io/npm/dt/cordova-plugin-apkupdater.svg)](https://www.npmjs.com/package/cordova-plugin-apkupdater)\n=========================\n\n![Cordova-Icon](https://raw.githubusercontent.com/wiki/kolbasa/cordova-plugin-apkupdater-demo/Images/CordovaBot.png)\n\nThis plugin enables you to update your Android app completely without the Google Play Store.\n\n:point_right: **[DEMO APP](https://github.com/kolbasa/cordova-plugin-apkupdater-demo)** :point_left:\n\n\u003cbr\u003e\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n- [Plugin requirements](#plugin-requirements)\n- [Installation](#installation)\n    - [Cordova](#cordova)\n    - [Ionic + Cordova](#ionic--cordova)\n    - [Capacitor](#capacitor)\n- [Basic example](#basic-example)\n    - [Ionic 2+ with Typescript](#ionic-2-with-typescript)\n    - [Cordova](#cordova-1)\n- [API](#api)\n  - [download()](#download)\n  - [stop()](#stop)\n  - [getInstalledVersion()](#getinstalledversion)\n  - [getDownloadedUpdate()](#getdownloadedupdate)\n  - [reset()](#reset)\n  - [install()](#install)\n    - [canRequestPackageInstalls()](#canrequestpackageinstalls)\n    - [openInstallSetting()](#openinstallsetting)\n  - [rootInstall()](#rootinstall)\n    - [isDeviceRooted()](#isdevicerooted)\n    - [requestRootAccess()](#requestrootaccess)\n  - [ownerInstall()](#ownerinstall)\n    - [isDeviceOwner()](#isdeviceowner)\n- [Update versioning](#update-versioning)\n- [License](#license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n\u003cbr\u003e\n\n# Plugin requirements\n\n* **Android**: `5+`\n* **cordova**: `10.0.0+`\n* **cordova-android**: `9.0.0+`\n\n\u003cbr\u003e\n\n# Installation\n\n### Cordova\n\n    cordova plugin add cordova-plugin-apkupdater\n\n### Ionic + Cordova\n\n    ionic cordova plugin add cordova-plugin-apkupdater\n\n### Capacitor\n\n    npm install cordova-plugin-apkupdater\n\n# Basic example\n\n### Ionic 2+ with Typescript\n\nHere is the simplest example: downloading and then installing the APK:\n\nSample Implementation:\n\n```ts\nimport ApkUpdater from 'cordova-plugin-apkupdater';\n\nexport class HomePage {\n\n    // .\n    // .\n    // .\n\n    async update() {\n        await ApkUpdater.download(\n            'https://your-update-server.com/update.apk',\n            {\n                onDownloadProgress: console.log\n            }\n        );\n        await ApkUpdater.install();\n    }\n\n}\n```\n\n([**Complete code sample**](doc/sample/Implementation.md))\n\n### Cordova\n\nThe same example with callbacks:\n\n```js\nApkUpdater.download(\n    'https://your-update-server.com/update.apk',\n    {\n        onDownloadProgress: console.log\n    },\n    function () {\n        ApkUpdater.install(console.log, console.error);\n    },\n    console.error\n);\n```\n\n\u003cbr\u003e\n\n# API\n\nThe JavaScript API supports **promises** and **callbacks** for all methods.  \nThe callback functions occupy the last two parameters.\n\n```js\n// promise\nawait ApkUpdater.download('https://your-update-server.com/update.apk', options);\n\n// alternative with callbacks\nApkUpdater.download('https://your-update-server.com/update.apk', options, success, failure);\n```\n\nOn this page I only show Promise examples for simplicity.\n\nIn case of a failure you get an error object with two attributes: `message` and `stack`.\n\nThis example...\n\n```js\ntry {\n    await ApkUpdater.download('https://wrong-url.com/update.apk');\n} catch (e) {\n    console.error(e.message + '\\n' + e.stack);\n}\n```\n\n... leads to the following output:\n\n```\nDownload failed: Unable to resolve host \"wrong-url.com\": No address associated with hostname\nde.kolbasa.apkupdater.exceptions.DownloadFailedException\n  at de.kolbasa.apkupdater.downloader.FileDownloader.download(FileDownloader.java:111)\n  at de.kolbasa.apkupdater.update.UpdateManager.downloadFile(UpdateManager.java:77)\n  at de.kolbasa.apkupdater.update.UpdateManager.download(UpdateManager.java:133)\n  at de.kolbasa.apkupdater.ApkUpdater.download(ApkUpdater.java:85)\n```\n\n\u003cbr\u003e\n\n## download()\n\n```js\nawait ApkUpdater.download('https://your-update-server.com/update.apk', options);\n```\n\nYou can also pass a `zip` file here. The zip file can even be encrypted with a password.  \nHowever, you should make sure that the archive contains only the APK file at root level, nothing else.  \nIf you want to automate this, then you can also use [my script](https://github.com/kolbasa/apk-update).\n\nConfiguration (optional):\n\n```js\nconst options = {\n    // ↓↓↓ If an encrypted zip file is used.\n    zipPassword: 'aDzEsCceP3BPO5jy', \n    // ↓↓↓ Authorization token\n    authorization: \"Basic \" + btoa('username:password'), // Example for basic access authentication\n    onDownloadProgress: function (e) {\n        console.log(\n            'Downloading: ' + e.progress + '%',\n            '(' + e.bytesWritten + '/' + e.bytes + ')'\n        );\n    },\n    onUnzipProgress: function (e) {\n        console.log(\n            'Unzipping: ' + e.progress + '%',\n            '(' + e.bytesWritten + '/' + e.bytes + ')'\n        );\n    }\n}\n```\n\nIf the download is successful, you will receive detailed information about the update file.\n\n```json\n{\n  \"name\": \"update.apk\",\n  \"path\": \"/data/user/0/de.kolbasa.apkupdater.demo/files/update\",\n  \"size\": 1982411,\n  \"app\": {\n    \"name\": \"Apk Updater Demo\",\n    \"package\": \"de.kolbasa.apkupdater.demo\",\n    \"version\": {\n      \"code\": 10001,\n      \"name\": \"1.0.1\"\n    }\n  }\n}\n```\n\n\u003cbr\u003e\n\n## stop()\n\nStops the download.\n\n```js\nawait ApkUpdater.stop();\n```\n\n\u003cbr\u003e\n\n## getInstalledVersion()\n\nProvides detailed information about the currently installed app version.\n\n```js\nawait ApkUpdater.getInstalledVersion();\n```\n\nExample output:\n\n```js\nconst result = {\n    \"name\": \"Apk Updater Demo\",\n    \"package\": \"de.kolbasa.apkupdater.demo\",\n    \"firstInstallTime\": 1625415754434, // Unix timestamp\n    \"version\": {\n        \"code\": 10000,\n        \"name\": \"1.0.0\"\n    }\n}\n```\n\n\u003cbr\u003e\n\n## getDownloadedUpdate()\n\nThe downloaded update remains saved even after an app restart and can be queried as follows:\n\n```js\nawait ApkUpdater.getDownloadedUpdate();\n```\n\nThe result uses the same format as the output from the `download()` method.\n\n\u003cbr\u003e\n\n## reset()\n\nThe `reset` method deletes all downloaded files.\n\nIt is mostly useful only for debugging purposes. The user himself has no access to the files.   \nThe plugin deletes old\nupdates automatically.\n\n```js\nawait ApkUpdater.reset();\n```\n\n\u003cbr\u003e\n\n## install()\n\nAs soon as the download has been completed, you can use this method to ask the user to install the APK.\n\n```js\nawait ApkUpdater.install();\n```\n\nWhen the method is invoked for the first time, the user is asked to enable a setting for installing third-party\napplications\n([video](https://raw.githubusercontent.com/wiki/kolbasa/cordova-plugin-apkupdater-demo/Videos/InstallSettings.gif)).\n\nYou may want to ask the user for this permission before installing the first update.  \nThe following two methods `canRequestPackageInstalls` and `openInstallSetting` are intended for this purpose.\n\n\n### canRequestPackageInstalls()\n\nQueries whether the installation of updates has been allowed.\n\n```js\nawait ApkUpdater.canRequestPackageInstalls(); // -\u003e true, false\n```\n\n### openInstallSetting()\n\nOpens the settings page\n([video](https://raw.githubusercontent.com/wiki/kolbasa/cordova-plugin-apkupdater-demo/Videos/OpenInstallSettings.gif)).\n\n```js\nawait ApkUpdater.openInstallSetting(); // -\u003e true, false\n```\n\n\u003cbr\u003e\n\n## rootInstall()\n\nIf you have a rooted device, then you can even set up unattended app update installations\n([video](https://raw.githubusercontent.com/wiki/kolbasa/cordova-plugin-apkupdater-demo/Videos/RootInstall.gif)).  \nIf you want to test this on an emulator, I can recommend the following script: [rootAVD](https://github.com/newbit1/rootAVD)\n\n```js\nawait ApkUpdater.rootInstall();\n```\n\n### isDeviceRooted()\n\n```js\nawait ApkUpdater.isDeviceRooted(); // -\u003e true, false\n```\n\n### requestRootAccess()\n\nRequests root access\n([video](https://raw.githubusercontent.com/wiki/kolbasa/cordova-plugin-apkupdater-demo/Videos/RequestRootAccess.gif)).\n\n```js\nawait ApkUpdater.requestRootAccess(); // -\u003e true, false\n```\n\n\u003cbr\u003e\n\n## ownerInstall()\n\nUnattended updates can also be used by apps that are registered as device owners\n([video](https://raw.githubusercontent.com/wiki/kolbasa/cordova-plugin-apkupdater-demo/Videos/OwnerInstall.gif)).  \n\n```js\nawait ApkUpdater.ownerInstall();\n```\n\nUnlike root access, this can be easily set up on any Android device. Instructions can be found [here](doc/DeviceOwner.md).\n\n### isDeviceOwner()\n\n```js\nawait ApkUpdater.isDeviceOwner(); // -\u003e true, false\n```\n\n\u003cbr\u003e\n\n# Update versioning\n\nThe plugin itself does not make a version comparison.  \nYou need to find a solution that best suits your use case.\n\nIf you always have Wi-Fi, you could download the entire apk at regular intervals and check whether the version has\nchanged.  \nIf you use mobile data, which is usually limited, then you should have a different strategy.  \nYou may already have a remote API and can request the latest version there.\n\nIn my case, I simply place a small `update.json` file next to the update, which stores the latest version number.  \nI then simply compare this version with the internal one, which I request with the `getInstalledVersion` method.\n\nThis is also the case with the\n[demo linked above](https://github.com/kolbasa/cordova-plugin-apkupdater-demo/tree/master/update).  \nHere is [my script](https://github.com/kolbasa/apk-update) that I use to create the compressed update and info file.\n\nSample Implementation:\n\n```ts\nimport ApkUpdater from 'cordova-plugin-apkupdater';\n\nexport class HomePage {\n\n    // .\n    // .\n    // .\n\n    remote = 'https://your-update-server.com'\n\n    async update() {\n        const manifest = await this.http.get\u003cUpdate\u003e(this.remote + '/update.json').toPromise();\n\n        const remoteVersion = manifest.app.version.code;\n        const installedVersion = (await ApkUpdater.getInstalledVersion()).version.code;\n\n        if (remoteVersion \u003e installedVersion) {\n            await ApkUpdater.download(this.remote + '/update.apk');\n            await ApkUpdater.install();\n        }\n    }\n}\n```\n\n([**Complete code sample**](doc/sample/Versioning.md))\n\n\u003cbr\u003e\n\n# License\n\nMIT License\n\nCopyright (c) 2021 Michael Jedich\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\ndocumentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\nrights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit\npersons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the\nSoftware.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\nWARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkolbasa%2Fcordova-plugin-apkupdater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkolbasa%2Fcordova-plugin-apkupdater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkolbasa%2Fcordova-plugin-apkupdater/lists"}