@simplysm/capacitor-plugin-auto-update 14.0.1 → 14.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -0
- package/dist/AutoUpdate.js +1 -1
- package/package.json +7 -7
- package/src/AutoUpdate.ts +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @simplysm/capacitor-plugin-auto-update
|
|
2
|
+
|
|
3
|
+
Capacitor auto-update plugin for Android APK installation and OTA updates.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @simplysm/capacitor-plugin-auto-update
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API Overview
|
|
12
|
+
|
|
13
|
+
### APK Installation
|
|
14
|
+
|
|
15
|
+
| API | Type | Description |
|
|
16
|
+
|-----|------|-------------|
|
|
17
|
+
| `VersionInfo` | Interface | App version information |
|
|
18
|
+
| `ApkInstallerPlugin` | Interface | Native plugin interface for APK installation |
|
|
19
|
+
| `ApkInstaller` | Class | Static API for APK installation, permission management, and version info |
|
|
20
|
+
|
|
21
|
+
### Auto Update
|
|
22
|
+
|
|
23
|
+
| API | Type | Description |
|
|
24
|
+
|-----|------|-------------|
|
|
25
|
+
| `AutoUpdate` | Class | Static API for downloading and installing APK updates from a server or external storage |
|
|
26
|
+
|
|
27
|
+
## Interfaces
|
|
28
|
+
|
|
29
|
+
### VersionInfo
|
|
30
|
+
|
|
31
|
+
Holds application version information.
|
|
32
|
+
|
|
33
|
+
| Field | Type | Description |
|
|
34
|
+
|-------|------|-------------|
|
|
35
|
+
| `versionName` | `string` | Human-readable version name (e.g. `"1.2.3"`) |
|
|
36
|
+
| `versionCode` | `string` | Numeric version code used by the Android system |
|
|
37
|
+
|
|
38
|
+
### ApkInstallerPlugin
|
|
39
|
+
|
|
40
|
+
Native plugin interface for APK installation.
|
|
41
|
+
|
|
42
|
+
| Method | Signature | Description |
|
|
43
|
+
|--------|-----------|-------------|
|
|
44
|
+
| `install` | `(options: { uri: string }) => Promise<void>` | Install APK from the given content URI |
|
|
45
|
+
| `checkPermissions` | `() => Promise<{ granted: boolean; manifest: boolean }>` | Check whether install permissions are granted |
|
|
46
|
+
| `requestPermissions` | `() => Promise<void>` | Request the `REQUEST_INSTALL_PACKAGES` permission |
|
|
47
|
+
| `getVersionInfo` | `() => Promise<VersionInfo>` | Retrieve current app version info |
|
|
48
|
+
|
|
49
|
+
## Classes
|
|
50
|
+
|
|
51
|
+
### ApkInstaller
|
|
52
|
+
|
|
53
|
+
APK installation plugin. On Android it runs the APK install intent and manages the `REQUEST_INSTALL_PACKAGES` permission. On the browser it shows a notification and returns normally.
|
|
54
|
+
|
|
55
|
+
All methods are static.
|
|
56
|
+
|
|
57
|
+
| Method | Signature | Description |
|
|
58
|
+
|--------|-----------|-------------|
|
|
59
|
+
| `checkPermissions` | `static async checkPermissions(): Promise<{ granted: boolean; manifest: boolean }>` | Check whether install permissions are currently granted |
|
|
60
|
+
| `requestPermissions` | `static async requestPermissions(): Promise<void>` | Request the `REQUEST_INSTALL_PACKAGES` permission from the user |
|
|
61
|
+
| `install` | `static async install(apkUri: string): Promise<void>` | Install an APK from a `content://` URI |
|
|
62
|
+
| `getVersionInfo` | `static async getVersionInfo(): Promise<VersionInfo>` | Get the current app version name and version code |
|
|
63
|
+
|
|
64
|
+
### AutoUpdate
|
|
65
|
+
|
|
66
|
+
Handles the full update flow: download an APK and install it.
|
|
67
|
+
|
|
68
|
+
All methods are static.
|
|
69
|
+
|
|
70
|
+
| Method | Signature | Description |
|
|
71
|
+
|--------|-----------|-------------|
|
|
72
|
+
| `run` | `static async run(opt: { log: (messageHtml: string) => void; serviceClient: ServiceClient }): Promise<void>` | Download the latest APK from a server via `ServiceClient` and install it. Progress is reported through the `log` callback as HTML strings. |
|
|
73
|
+
| `runByExternalStorage` | `static async runByExternalStorage(opt: { log: (messageHtml: string) => void; dirPath: string }): Promise<void>` | Find the latest APK file from an external storage directory and install it. Progress is reported through the `log` callback. |
|
|
74
|
+
|
|
75
|
+
## Usage Examples
|
|
76
|
+
|
|
77
|
+
### Check permissions and install an APK
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { ApkInstaller } from "@simplysm/capacitor-plugin-auto-update";
|
|
81
|
+
|
|
82
|
+
const perms = await ApkInstaller.checkPermissions();
|
|
83
|
+
if (!perms.granted) {
|
|
84
|
+
await ApkInstaller.requestPermissions();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
await ApkInstaller.install("content://com.example.provider/apk/update.apk");
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Auto-update from a server
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
|
|
94
|
+
|
|
95
|
+
await AutoUpdate.run({
|
|
96
|
+
log: (messageHtml) => {
|
|
97
|
+
document.getElementById("status")!.innerHTML = messageHtml;
|
|
98
|
+
},
|
|
99
|
+
serviceClient: myServiceClient,
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Auto-update from external storage
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
|
|
107
|
+
|
|
108
|
+
await AutoUpdate.runByExternalStorage({
|
|
109
|
+
log: (messageHtml) => {
|
|
110
|
+
document.getElementById("status")!.innerHTML = messageHtml;
|
|
111
|
+
},
|
|
112
|
+
dirPath: "/storage/emulated/0/Download/updates",
|
|
113
|
+
});
|
|
114
|
+
```
|
package/dist/AutoUpdate.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/capacitor-plugin-auto-update",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.4",
|
|
4
4
|
"description": "심플리즘 패키지 - Capacitor 자동 업데이트 플러그인",
|
|
5
5
|
"author": "심플리즘",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"semver": "^7.7.4",
|
|
22
|
-
"@simplysm/
|
|
23
|
-
"@simplysm/
|
|
24
|
-
"@simplysm/service-
|
|
25
|
-
"@simplysm/core-common": "14.0.
|
|
26
|
-
"@simplysm/
|
|
22
|
+
"@simplysm/capacitor-plugin-file-system": "14.0.4",
|
|
23
|
+
"@simplysm/core-browser": "14.0.4",
|
|
24
|
+
"@simplysm/service-client": "14.0.4",
|
|
25
|
+
"@simplysm/core-common": "14.0.4",
|
|
26
|
+
"@simplysm/service-common": "14.0.4"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@capacitor/core": "^7.6.
|
|
29
|
+
"@capacitor/core": "^7.6.1",
|
|
30
30
|
"@types/semver": "^7.7.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|