@simplysm/capacitor-plugin-auto-update 13.0.96 → 13.0.98
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 +81 -97
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,140 +1,124 @@
|
|
|
1
1
|
# @simplysm/capacitor-plugin-auto-update
|
|
2
2
|
|
|
3
|
-
Capacitor
|
|
3
|
+
Capacitor Auto Update Plugin -- APK installation and OTA update for Android Capacitor apps.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @simplysm/capacitor-plugin-auto-update
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
**Peer:** `@capacitor/core` ^7.4.4
|
|
11
|
+
## API Overview
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
### Types
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export { AutoUpdate } from "./AutoUpdate";
|
|
20
|
-
export type { ApkInstallerPlugin, VersionInfo } from "./ApkInstallerPlugin";
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## 주요 사용법
|
|
15
|
+
| API | Type | Description |
|
|
16
|
+
|-----|------|-------------|
|
|
17
|
+
| `VersionInfo` | interface | App version info (`versionName`, `versionCode`) |
|
|
24
18
|
|
|
25
|
-
###
|
|
19
|
+
### Interfaces
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
| API | Type | Description |
|
|
22
|
+
|-----|------|-------------|
|
|
23
|
+
| `ApkInstallerPlugin` | interface | Low-level Capacitor plugin interface for APK operations |
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
|
|
31
|
-
import type { ServiceClient } from "@simplysm/service-client";
|
|
25
|
+
### Classes
|
|
32
26
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
```
|
|
27
|
+
| API | Type | Description |
|
|
28
|
+
|-----|------|-------------|
|
|
29
|
+
| `ApkInstaller` | abstract class | APK installation and permission management |
|
|
30
|
+
| `AutoUpdate` | abstract class | OTA update flow (server-based or external storage) |
|
|
40
31
|
|
|
41
|
-
|
|
42
|
-
1. 서버에서 최신 버전 조회 (`AutoUpdateService.getLastVersion("android")`)
|
|
43
|
-
2. `REQUEST_INSTALL_PACKAGES` 권한 확인/요청 (매니페스트 미선언 시 재설치 유도)
|
|
44
|
-
3. 현재 앱 버전과 semver 비교 (최신이면 조기 반환)
|
|
45
|
-
4. APK 다운로드 (`fetchUrlBytes`, 진행률 콜백)
|
|
46
|
-
5. `appCache` 경로에 `latest.apk`로 저장
|
|
47
|
-
6. APK 설치 인텐트 실행 후 앱 정지 (`await new Promise(() => {})`)
|
|
32
|
+
## `VersionInfo`
|
|
48
33
|
|
|
49
|
-
서버 서비스 인터페이스 (`@simplysm/service-common`):
|
|
50
34
|
```typescript
|
|
51
|
-
interface
|
|
52
|
-
|
|
35
|
+
interface VersionInfo {
|
|
36
|
+
versionName: string;
|
|
37
|
+
versionCode: string;
|
|
53
38
|
}
|
|
54
39
|
```
|
|
55
40
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
USB 또는 SD카드 등 외부 스토리지의 APK 파일로 업데이트한다. 파일명이 semver 형식이어야 한다 (예: `1.2.3.apk`).
|
|
41
|
+
## `ApkInstallerPlugin`
|
|
59
42
|
|
|
60
43
|
```typescript
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
44
|
+
interface ApkInstallerPlugin {
|
|
45
|
+
install(options: { uri: string }): Promise<void>;
|
|
46
|
+
checkPermissions(): Promise<{ granted: boolean; manifest: boolean }>;
|
|
47
|
+
requestPermissions(): Promise<void>;
|
|
48
|
+
getVersionInfo(): Promise<VersionInfo>;
|
|
49
|
+
}
|
|
67
50
|
```
|
|
68
51
|
|
|
69
|
-
|
|
70
|
-
1. `REQUEST_INSTALL_PACKAGES` 권한 확인/요청
|
|
71
|
-
2. 외부 스토리지의 `dirPath`에서 `.apk` 파일 목록 조회
|
|
72
|
-
3. 파일명(`1.2.3.apk` -> `1.2.3`)을 semver로 파싱하여 최신 버전 선택
|
|
73
|
-
4. 현재 앱 버전과 비교 후 설치
|
|
52
|
+
Low-level Capacitor plugin interface. Use `ApkInstaller` static methods instead of calling this directly.
|
|
74
53
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
`ApkInstaller`는 `AutoUpdate` 내부에서 사용되지만, 직접 호출도 가능하다.
|
|
54
|
+
## `ApkInstaller`
|
|
78
55
|
|
|
79
56
|
```typescript
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
57
|
+
abstract class ApkInstaller {
|
|
58
|
+
static async checkPermissions(): Promise<{ granted: boolean; manifest: boolean }>;
|
|
59
|
+
static async requestPermissions(): Promise<void>;
|
|
60
|
+
static async install(apkUri: string): Promise<void>;
|
|
61
|
+
static async getVersionInfo(): Promise<VersionInfo>;
|
|
62
|
+
}
|
|
63
|
+
```
|
|
85
64
|
|
|
86
|
-
|
|
87
|
-
|
|
65
|
+
APK installation plugin.
|
|
66
|
+
- Android: Executes APK install intent, manages `REQUEST_INSTALL_PACKAGES` permission.
|
|
67
|
+
- Browser: Shows alert message and returns normally.
|
|
88
68
|
|
|
89
|
-
|
|
90
|
-
await ApkInstaller.install(apkUri);
|
|
69
|
+
## `AutoUpdate`
|
|
91
70
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
71
|
+
```typescript
|
|
72
|
+
abstract class AutoUpdate {
|
|
73
|
+
static async run(opt: {
|
|
74
|
+
log: (messageHtml: string) => void;
|
|
75
|
+
serviceClient: ServiceClient;
|
|
76
|
+
}): Promise<void>;
|
|
77
|
+
|
|
78
|
+
static async runByExternalStorage(opt: {
|
|
79
|
+
log: (messageHtml: string) => void;
|
|
80
|
+
dirPath: string;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
}
|
|
95
83
|
```
|
|
96
84
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
### `AutoUpdate` (abstract class, static 메서드)
|
|
100
|
-
|
|
101
|
-
| 메서드 | 시그니처 | 설명 |
|
|
102
|
-
|--------|----------|------|
|
|
103
|
-
| `run` | `(opt: { log: (messageHtml: string) => void; serviceClient: ServiceClient }) => Promise<void>` | 서버 기반 자동 업데이트 |
|
|
104
|
-
| `runByExternalStorage` | `(opt: { log: (messageHtml: string) => void; dirPath: string }) => Promise<void>` | 외부 스토리지 기반 업데이트 |
|
|
85
|
+
- `run` -- Downloads the latest APK from a service server and installs it. Compares versions via semver.
|
|
86
|
+
- `runByExternalStorage` -- Finds the latest APK file in an external storage directory and installs it.
|
|
105
87
|
|
|
106
|
-
|
|
88
|
+
Both methods check install permissions, display progress via the `log` callback (HTML), and freeze the app after installation to await restart.
|
|
107
89
|
|
|
108
|
-
|
|
109
|
-
|--------|----------|------|
|
|
110
|
-
| `checkPermissions` | `() => Promise<{ granted: boolean; manifest: boolean }>` | 설치 권한 확인 |
|
|
111
|
-
| `requestPermissions` | `() => Promise<void>` | 설치 권한 요청 |
|
|
112
|
-
| `install` | `(apkUri: string) => Promise<void>` | APK 설치 (content:// URI) |
|
|
113
|
-
| `getVersionInfo` | `() => Promise<VersionInfo>` | 앱 버전 정보 조회 |
|
|
90
|
+
## Usage Examples
|
|
114
91
|
|
|
115
|
-
###
|
|
92
|
+
### Check permissions and install APK
|
|
116
93
|
|
|
117
94
|
```typescript
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
95
|
+
import { ApkInstaller } from "@simplysm/capacitor-plugin-auto-update";
|
|
96
|
+
|
|
97
|
+
const perms = await ApkInstaller.checkPermissions();
|
|
98
|
+
if (!perms.granted) {
|
|
99
|
+
await ApkInstaller.requestPermissions();
|
|
121
100
|
}
|
|
101
|
+
await ApkInstaller.install("content://com.example.provider/latest.apk");
|
|
122
102
|
```
|
|
123
103
|
|
|
124
|
-
|
|
104
|
+
### Server-based auto update
|
|
125
105
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
| APK 설치 | FileProvider URI + ACTION_VIEW 인텐트 | alert 표시 후 정상 반환 |
|
|
129
|
-
| 버전 확인 | PackageManager API | `import.meta.env.__VER__` (기본값 `"0.0.0"`) |
|
|
130
|
-
| 권한 관리 | REQUEST_INSTALL_PACKAGES (Android 8+) | 항상 granted/manifest = true |
|
|
131
|
-
| 권한 설정 이동 | ACTION_MANAGE_UNKNOWN_APP_SOURCES | no-op |
|
|
106
|
+
```typescript
|
|
107
|
+
import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
|
|
132
108
|
|
|
133
|
-
|
|
109
|
+
await AutoUpdate.run({
|
|
110
|
+
log: (html) => { document.getElementById("status")!.innerHTML = html; },
|
|
111
|
+
serviceClient: myServiceClient,
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### External storage auto update
|
|
134
116
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
117
|
+
```typescript
|
|
118
|
+
import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
|
|
119
|
+
|
|
120
|
+
await AutoUpdate.runByExternalStorage({
|
|
121
|
+
log: (html) => { document.getElementById("status")!.innerHTML = html; },
|
|
122
|
+
dirPath: "MyApp/updates",
|
|
123
|
+
});
|
|
124
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/capacitor-plugin-auto-update",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.98",
|
|
4
4
|
"description": "Simplysm Package - Capacitor Auto Update Plugin",
|
|
5
5
|
"author": "simplysm",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"semver": "^7.7.4",
|
|
22
|
-
"@simplysm/capacitor-plugin-file-system": "13.0.
|
|
23
|
-
"@simplysm/core-browser": "13.0.
|
|
24
|
-
"@simplysm/
|
|
25
|
-
"@simplysm/
|
|
26
|
-
"@simplysm/service-common": "13.0.
|
|
22
|
+
"@simplysm/capacitor-plugin-file-system": "13.0.98",
|
|
23
|
+
"@simplysm/core-browser": "13.0.98",
|
|
24
|
+
"@simplysm/service-client": "13.0.98",
|
|
25
|
+
"@simplysm/core-common": "13.0.98",
|
|
26
|
+
"@simplysm/service-common": "13.0.98"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@capacitor/core": "^7.6.0",
|