Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/capawesome-team/capacitor-app-update
⚡️ Capacitor plugin that assists with app updates.
https://github.com/capawesome-team/capacitor-app-update
List: capacitor-app-update
android capacitor capacitor-community capacitor-plugin capawesome in-app-update ios
Last synced: 2 months ago
JSON representation
⚡️ Capacitor plugin that assists with app updates.
- Host: GitHub
- URL: https://github.com/capawesome-team/capacitor-app-update
- Owner: capawesome-team
- License: mit
- Archived: true
- Created: 2021-01-17T19:48:24.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-04-01T07:18:34.000Z (almost 2 years ago)
- Last Synced: 2024-10-29T16:20:22.026Z (3 months ago)
- Topics: android, capacitor, capacitor-community, capacitor-plugin, capawesome, in-app-update, ios
- Language: Java
- Homepage: https://capawesome.io/plugins/app-update/
- Size: 939 KB
- Stars: 119
- Watchers: 8
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-capacitor - Native updates - Capacitor plugin that assists with app updates. ([Capawesome plugins](https://capawesome.io/))
README
## ⚠️ Deprecated repository
**This project has been moved to the following monorepo: [capawesome-team/capacitor-plugins](https://github.com/capawesome-team/capacitor-plugins).**
-----
App Update
@capawesome/capacitor-app-update
Capacitor plugin that assists with app updates.This plugin supports retrieving app update information on **Android** and **iOS**.
Additionally, this plugin supports [in-app updates](https://developer.android.com/guide/playcore/in-app-updates) on **Android**.## Maintainers
| Maintainer | GitHub | Social |
| ---------- | ----------------------------------------- | --------------------------------------------- |
| Robin Genz | [robingenz](https://github.com/robingenz) | [@robin_genz](https://twitter.com/robin_genz) |## Sponsors
This is an MIT-licensed open source project.
It can grow thanks to the support by these awesome people.
If you'd like to join them, please read more [here](https://github.com/sponsors/capawesome-team).## Installation
```bash
npm install @capawesome/capacitor-app-update
npx cap sync
```### Android Variables
This plugin will use the following project variables (defined in your app’s `variables.gradle` file):
- `$androidPlayCore` version of `com.google.android.play:core` (default: `1.9.0`)
- `$androidPlayServicesBaseVersion` version of `com.google.android.gms:play-services-base` (default: `18.0.1`)## Configuration
No configuration required for this plugin.
## Demo
A working example can be found here: [robingenz/capacitor-plugin-demo](https://github.com/robingenz/capacitor-plugin-demo)
## Usage
```typescript
import { AppUpdate } from '@capawesome/capacitor-app-update';const getCurrentAppVersion = async () => {
const result = await AppUpdate.getAppUpdateInfo();
return result.currentVersion;
};const getAvailableAppVersion = async () => {
const result = await AppUpdate.getAppUpdateInfo();
return result.availableVersion;
};const openAppStore = async () => {
await AppUpdate.openAppStore();
};const performImmediateUpdate = async () => {
const result = await AppUpdate.getAppUpdateInfo();
if (result.updateAvailability !== AppUpdateAvailability.UPDATE_AVAILABLE) {
return;
}
if (result.immediateUpdateAllowed) {
await AppUpdate.performImmediateUpdate();
}
};const startFlexibleUpdate = async () => {
const result = await AppUpdate.getAppUpdateInfo();
if (result.updateAvailability !== AppUpdateAvailability.UPDATE_AVAILABLE) {
return;
}
if (result.flexibleUpdateAllowed) {
await AppUpdate.startFlexibleUpdate();
}
};const completeFlexibleUpdate = async () => {
await AppUpdate.completeFlexibleUpdate();
};
```## API
* [`getAppUpdateInfo(...)`](#getappupdateinfo)
* [`openAppStore(...)`](#openappstore)
* [`performImmediateUpdate()`](#performimmediateupdate)
* [`startFlexibleUpdate()`](#startflexibleupdate)
* [`completeFlexibleUpdate()`](#completeflexibleupdate)
* [`addListener('onFlexibleUpdateStateChange', ...)`](#addlisteneronflexibleupdatestatechange)
* [`removeAllListeners()`](#removealllisteners)
* [Interfaces](#interfaces)
* [Enums](#enums)### getAppUpdateInfo(...)
```typescript
getAppUpdateInfo(options?: GetAppUpdateInfoOptions | undefined) => Promise
```Returns app update informations.
Only available for Android and iOS.
| Param | Type |
| ------------- | --------------------------------------------------------------------------- |
| **`options`** |GetAppUpdateInfoOptions
|**Returns:**
Promise<AppUpdateInfo>
--------------------
### openAppStore(...)
```typescript
openAppStore(options?: OpenAppStoreOptions | undefined) => Promise
```Opens the app store entry of the app in the Play Store (Android) or App Store (iOS).
Only available for Android and iOS.
| Param | Type |
| ------------- | ------------------------------------------------------------------- |
| **`options`** |OpenAppStoreOptions
|--------------------
### performImmediateUpdate()
```typescript
performImmediateUpdate() => Promise
```Performs an immediate in-app update.
Only available for Android.
**Returns:**
Promise<AppUpdateResult>
--------------------
### startFlexibleUpdate()
```typescript
startFlexibleUpdate() => Promise
```Starts a flexible in-app update.
Only available for Android.
**Returns:**
Promise<AppUpdateResult>
--------------------
### completeFlexibleUpdate()
```typescript
completeFlexibleUpdate() => Promise
```Completes a flexible in-app update by restarting the app.
Only available for Android.
--------------------
### addListener('onFlexibleUpdateStateChange', ...)
```typescript
addListener(eventName: 'onFlexibleUpdateStateChange', listenerFunc: (state: FlexibleUpdateState) => void) => PluginListenerHandle
```Adds a flexbile in-app update state change listener.
Only available for Android.
| Param | Type |
| ------------------ | --------------------------------------------------------------------------------------- |
| **`eventName`** |'onFlexibleUpdateStateChange'
|
| **`listenerFunc`** |(state: FlexibleUpdateState) => void
|**Returns:**
PluginListenerHandle
--------------------
### removeAllListeners()
```typescript
removeAllListeners() => Promise
```Remove all listeners for this plugin.
--------------------
### Interfaces
#### AppUpdateInfo
| Prop | Type | Description |
| --------------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **`currentVersion`** |string
| Version code (Android) or CFBundleShortVersionString (iOS) of the currently installed app version. Only available for Android and iOS. |
| **`availableVersion`** |string
| Version code (Android) or CFBundleShortVersionString (iOS) of the update. Only available for Android and iOS. |
| **`availableVersionReleaseDate`** |string
| Release date of the update in ISO 8601 (UTC) format. Only available for iOS. |
| **`updateAvailability`** |AppUpdateAvailability
| The app update availability. Only available for Android and iOS. |
| **`updatePriority`** |number
| In-app update priority for this update, as defined by the developer in the Google Play Developer API. Only available for Android. |
| **`immediateUpdateAllowed`** |boolean
| `true` if an immediate update is allowed, otherwise `false`. Only available for Android. |
| **`flexibleUpdateAllowed`** |boolean
| `true` if a flexible update is allowed, otherwise `false`. Only available for Android. |
| **`clientVersionStalenessDays`** |number
| Number of days since the Google Play Store app on the user's device has learnt about an available update if an update is available or in progress. Only available for Android. |
| **`installStatus`** |FlexibleUpdateInstallStatus
| Flexible in-app update install status. Only available for Android. |
| **`minimumOsVersion`** |string
| The minimum version of the operating system required for the app to run in iOS. Only available for iOS. |#### GetAppUpdateInfoOptions
| Prop | Type | Description |
| ------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`country`** |string
| The two-letter country code for the store you want to search. See http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 for a list of ISO Country Codes. Only available for iOS. |#### OpenAppStoreOptions
| Prop | Type | Description |
| ------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`country`** |string
| The two-letter country code for the store you want to search. See http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 for a list of ISO Country Codes. Only available for iOS. |#### AppUpdateResult
| Prop | Type |
| ---------- | ------------------------------------------------------------------- |
| **`code`** |AppUpdateResultCode
|#### PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| **`remove`** |() => Promise<void>
|#### FlexibleUpdateState
| Prop | Type | Description |
| -------------------------- | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| **`installStatus`** |FlexibleUpdateInstallStatus
| Flexible in-app update install status. |
| **`bytesDownloaded`** |number
| Returns the number of bytes downloaded so far. `undefined` if the install status is other than `DOWNLOADING`. |
| **`totalBytesToDownload`** |number
| Returns the total number of bytes to be downloaded for this update. `undefined` if the install status is other than `DOWNLOADING`. |### Enums
#### AppUpdateAvailability
| Members | Value |
| -------------------------- | -------------- |
| **`UNKNOWN`** |0
|
| **`UPDATE_NOT_AVAILABLE`** |1
|
| **`UPDATE_AVAILABLE`** |2
|
| **`UPDATE_IN_PROGRESS`** |3
|#### FlexibleUpdateInstallStatus
| Members | Value |
| ----------------- | --------------- |
| **`UNKNOWN`** |0
|
| **`PENDING`** |1
|
| **`DOWNLOADING`** |2
|
| **`INSTALLING`** |3
|
| **`INSTALLED`** |4
|
| **`FAILED`** |5
|
| **`CANCELED`** |6
|
| **`DOWNLOADED`** |11
|#### AppUpdateResultCode
| Members | Value | Description |
| ------------------- | -------------- | ------------------------------------------------------------------------------------------- |
| **`OK`** |0
| The user has accepted the update. |
| **`CANCELED`** |1
| The user has denied or cancelled the update. |
| **`FAILED`** |2
| Some other error prevented either the user from providing consent or the update to proceed. |
| **`NOT_AVAILABLE`** |3
| No update available. |
| **`NOT_ALLOWED`** |4
| Update type not allowed. |
| **`INFO_MISSING`** |5
| App update info missing. You must call `getAppUpdateInfo()` before requesting an update. |## Test with internal app-sharing
The Android Developers documentation describes how to test [in-app updates](https://developer.android.com/guide/playcore/in-app-updates) using [internal app sharing](https://support.google.com/googleplay/android-developer/answer/9303479): https://developer.android.com/guide/playcore/in-app-updates/test
## Changelog
See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-app-update/blob/main/CHANGELOG.md).
## License
See [LICENSE](https://github.com/capawesome-team/capacitor-app-update/blob/main/LICENSE).