@simplysm/capacitor-plugin-auto-update 12.16.30 → 12.16.35

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.
Files changed (2) hide show
  1. package/README.md +143 -0
  2. package/package.json +7 -7
package/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # @simplysm/capacitor-plugin-auto-update
2
+
3
+ Capacitor Auto Update Plugin -- APK installation and OTA update for Android/Browser. Manages `REQUEST_INSTALL_PACKAGES` permission, installs APK files via intent, retrieves app version info, and provides a full OTA update flow via `SdServiceClient` or external storage.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @simplysm/capacitor-plugin-auto-update
9
+ ```
10
+
11
+ ## API Overview
12
+
13
+ | API | Type | Description |
14
+ |-----|------|-------------|
15
+ | `ApkInstaller` | Abstract class | Static methods for APK installation permission management, APK install, and version info retrieval |
16
+ | `AutoUpdate` | Abstract class | Static methods for OTA auto-update flows (server-based and external-storage-based) |
17
+ | `IApkInstallerPlugin` | Interface | Low-level Capacitor plugin interface for APK installation |
18
+ | `IVersionInfo` | Interface | App version information structure |
19
+
20
+ ## API Reference
21
+
22
+ ### `IVersionInfo`
23
+
24
+ App version information returned by `ApkInstaller.getVersionInfo()`.
25
+
26
+ ```typescript
27
+ export interface IVersionInfo {
28
+ versionName: string;
29
+ versionCode: string;
30
+ }
31
+ ```
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 Android |
37
+
38
+ ### `IApkInstallerPlugin`
39
+
40
+ Low-level Capacitor plugin interface. Use `ApkInstaller` instead for a simplified API.
41
+
42
+ ```typescript
43
+ export interface IApkInstallerPlugin {
44
+ install(options: { uri: string }): Promise<void>;
45
+ hasPermission(): Promise<{ granted: boolean }>;
46
+ requestPermission(): Promise<void>;
47
+ hasPermissionManifest(): Promise<{ declared: boolean }>;
48
+ getVersionInfo(): Promise<IVersionInfo>;
49
+ }
50
+ ```
51
+
52
+ | Method | Parameters | Returns | Description |
53
+ |--------|------------|---------|-------------|
54
+ | `install` | `options: { uri: string }` | `Promise<void>` | Install an APK from a content:// URI |
55
+ | `hasPermission` | -- | `Promise<{ granted: boolean }>` | Check if install permission is granted |
56
+ | `requestPermission` | -- | `Promise<void>` | Request install permission (opens settings) |
57
+ | `hasPermissionManifest` | -- | `Promise<{ declared: boolean }>` | Check if permission is declared in manifest |
58
+ | `getVersionInfo` | -- | `Promise<IVersionInfo>` | Get current app version info |
59
+
60
+ ### `ApkInstaller`
61
+
62
+ Abstract class with static methods for APK installation and permission management.
63
+
64
+ - **Android**: Executes APK install intents, manages `REQUEST_INSTALL_PACKAGES` permission
65
+ - **Browser**: Shows alert and returns normally
66
+
67
+ ```typescript
68
+ export abstract class ApkInstaller {
69
+ static async hasPermissionManifest(): Promise<boolean>;
70
+ static async hasPermission(): Promise<boolean>;
71
+ static async requestPermission(): Promise<void>;
72
+ static async install(apkUri: string): Promise<void>;
73
+ static async getVersionInfo(): Promise<IVersionInfo>;
74
+ }
75
+ ```
76
+
77
+ | Method | Parameters | Returns | Description |
78
+ |--------|------------|---------|-------------|
79
+ | `hasPermissionManifest` | -- | `Promise<boolean>` | Check if `REQUEST_INSTALL_PACKAGES` is declared in the AndroidManifest |
80
+ | `hasPermission` | -- | `Promise<boolean>` | Check if install packages permission is currently granted |
81
+ | `requestPermission` | -- | `Promise<void>` | Request install permission (navigates to settings screen) |
82
+ | `install` | `apkUri: string` | `Promise<void>` | Install an APK from a `content://` URI (FileProvider URI) |
83
+ | `getVersionInfo` | -- | `Promise<IVersionInfo>` | Retrieve the current app version name and code |
84
+
85
+ ### `AutoUpdate`
86
+
87
+ Abstract class providing a complete OTA auto-update flow. Supports two modes: server-based update via `SdServiceClient` and external-storage-based update from APK files on the device.
88
+
89
+ ```typescript
90
+ export abstract class AutoUpdate {
91
+ static async runAsync(opt: {
92
+ log: (messageHtml: string) => void;
93
+ serviceClient: SdServiceClient;
94
+ }): Promise<void>;
95
+
96
+ static async runByExternalStorageAsync(opt: {
97
+ log: (messageHtml: string) => void;
98
+ dirPath: string;
99
+ }): Promise<void>;
100
+ }
101
+ ```
102
+
103
+ | Method | Parameters | Returns | Description |
104
+ |--------|------------|---------|-------------|
105
+ | `runAsync` | `opt: { log, serviceClient }` | `Promise<void>` | Run OTA update: check server version via `SdServiceClient`, download APK, and install |
106
+ | `runByExternalStorageAsync` | `opt: { log, dirPath }` | `Promise<void>` | Run update from external storage: scan `dirPath` for APK files, find latest version via semver, and install |
107
+
108
+ ## Usage Examples
109
+
110
+ ### Check permission and install an APK
111
+
112
+ ```typescript
113
+ import { ApkInstaller } from "@simplysm/capacitor-plugin-auto-update";
114
+
115
+ // Check if install permission is granted
116
+ const hasPermission = await ApkInstaller.hasPermission();
117
+ if (!hasPermission) {
118
+ await ApkInstaller.requestPermission();
119
+ }
120
+
121
+ // Install APK from a content:// URI
122
+ await ApkInstaller.install("content://com.example.fileprovider/apk/update.apk");
123
+
124
+ // Get current app version
125
+ const versionInfo = await ApkInstaller.getVersionInfo();
126
+ console.log(versionInfo.versionName, versionInfo.versionCode);
127
+ ```
128
+
129
+ ### Run OTA auto-update from server
130
+
131
+ ```typescript
132
+ import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
133
+ import { SdServiceClient } from "@simplysm/sd-service-client";
134
+
135
+ const serviceClient = new SdServiceClient("https://my-server.com");
136
+
137
+ await AutoUpdate.runAsync({
138
+ log: (messageHtml) => {
139
+ document.getElementById("status")!.innerHTML = messageHtml;
140
+ },
141
+ serviceClient,
142
+ });
143
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/capacitor-plugin-auto-update",
3
- "version": "12.16.30",
3
+ "version": "12.16.35",
4
4
  "description": "심플리즘 패키지 - Capacitor Plugin Auto Update",
5
5
  "author": "김석래",
6
6
  "repository": {
@@ -18,18 +18,18 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
- "@simplysm/sd-core-common": "12.16.30",
22
- "@simplysm/sd-service-client": "12.16.30",
23
- "@simplysm/sd-service-common": "12.16.30",
21
+ "@simplysm/sd-core-common": "12.16.35",
22
+ "@simplysm/sd-service-client": "12.16.35",
23
+ "@simplysm/sd-service-common": "12.16.35",
24
24
  "semver": "^7.7.4"
25
25
  },
26
26
  "devDependencies": {
27
- "@capacitor/core": "^7.5.0",
28
- "@simplysm/capacitor-plugin-file-system": "12.16.30",
27
+ "@capacitor/core": "^7.6.0",
28
+ "@simplysm/capacitor-plugin-file-system": "12.16.35",
29
29
  "@types/semver": "^7.7.1"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@capacitor/core": "^7.0.0",
33
- "@simplysm/capacitor-plugin-file-system": "12.16.30"
33
+ "@simplysm/capacitor-plugin-file-system": "12.16.35"
34
34
  }
35
35
  }