@simplysm/capacitor-plugin-auto-update 14.0.4 → 14.0.6

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 +80 -29
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # @simplysm/capacitor-plugin-auto-update
2
2
 
3
- Capacitor auto-update plugin for Android APK installation and OTA updates.
3
+ Capacitor plugin for automatic APK updates on Android. Provides APK installation with permission management and automatic update flows via a remote server or external storage.
4
+
5
+ - **Android**: Launches APK install intents, manages `REQUEST_INSTALL_PACKAGES` permission
6
+ - **Browser**: Displays notification messages and returns normally (for development)
4
7
 
5
8
  ## Installation
6
9
 
@@ -10,76 +13,124 @@ npm install @simplysm/capacitor-plugin-auto-update
10
13
 
11
14
  ## API Overview
12
15
 
13
- ### APK Installation
16
+ ### Interfaces
14
17
 
15
18
  | API | Type | Description |
16
19
  |-----|------|-------------|
17
20
  | `VersionInfo` | Interface | App version information |
18
21
  | `ApkInstallerPlugin` | Interface | Native plugin interface for APK installation |
19
- | `ApkInstaller` | Class | Static API for APK installation, permission management, and version info |
20
22
 
21
- ### Auto Update
23
+ ### Classes
22
24
 
23
25
  | API | Type | Description |
24
26
  |-----|------|-------------|
27
+ | `ApkInstaller` | Class | Static API for APK installation, permission management, and version info |
25
28
  | `AutoUpdate` | Class | Static API for downloading and installing APK updates from a server or external storage |
26
29
 
27
- ## Interfaces
28
-
29
- ### VersionInfo
30
+ ## `VersionInfo`
30
31
 
31
32
  Holds application version information.
32
33
 
34
+ ```typescript
35
+ interface VersionInfo {
36
+ versionName: string;
37
+ versionCode: string;
38
+ }
39
+ ```
40
+
33
41
  | Field | Type | Description |
34
42
  |-------|------|-------------|
35
43
  | `versionName` | `string` | Human-readable version name (e.g. `"1.2.3"`) |
36
44
  | `versionCode` | `string` | Numeric version code used by the Android system |
37
45
 
38
- ### ApkInstallerPlugin
46
+ ## `ApkInstallerPlugin`
39
47
 
40
- Native plugin interface for APK installation.
48
+ Native plugin interface for APK installation. Use the `ApkInstaller` class for a simplified API.
49
+
50
+ ```typescript
51
+ interface ApkInstallerPlugin {
52
+ install(options: { uri: string }): Promise<void>;
53
+ checkPermissions(): Promise<{ granted: boolean; manifest: boolean }>;
54
+ requestPermissions(): Promise<void>;
55
+ getVersionInfo(): Promise<VersionInfo>;
56
+ }
57
+ ```
41
58
 
42
59
  | Method | Signature | Description |
43
60
  |--------|-----------|-------------|
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 |
61
+ | `install` | `(options: { uri: string }) => Promise<void>` | Install APK from the given `content://` URI |
62
+ | `checkPermissions` | `() => Promise<{ granted: boolean; manifest: boolean }>` | Check whether install permissions are granted and declared in manifest |
46
63
  | `requestPermissions` | `() => Promise<void>` | Request the `REQUEST_INSTALL_PACKAGES` permission |
47
64
  | `getVersionInfo` | `() => Promise<VersionInfo>` | Retrieve current app version info |
48
65
 
49
- ## Classes
66
+ ## `ApkInstaller`
50
67
 
51
- ### ApkInstaller
68
+ Abstract class with static methods for APK installation and permission management. 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.
52
69
 
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.
70
+ ```typescript
71
+ abstract class ApkInstaller {
72
+ static async checkPermissions(): Promise<{ granted: boolean; manifest: boolean }>;
73
+ static async requestPermissions(): Promise<void>;
74
+ static async install(apkUri: string): Promise<void>;
75
+ static async getVersionInfo(): Promise<VersionInfo>;
76
+ }
77
+ ```
56
78
 
57
79
  | Method | Signature | Description |
58
80
  |--------|-----------|-------------|
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 |
81
+ | `checkPermissions` | `static async checkPermissions(): Promise<{ granted: boolean; manifest: boolean }>` | Check whether install permission is granted and declared in manifest |
82
+ | `requestPermissions` | `static async requestPermissions(): Promise<void>` | Request `REQUEST_INSTALL_PACKAGES` permission (navigates to settings screen) |
83
+ | `install` | `static async install(apkUri: string): Promise<void>` | Install an APK from a `content://` URI (FileProvider URI) |
62
84
  | `getVersionInfo` | `static async getVersionInfo(): Promise<VersionInfo>` | Get the current app version name and version code |
63
85
 
64
- ### AutoUpdate
86
+ ## `AutoUpdate`
65
87
 
66
- Handles the full update flow: download an APK and install it.
88
+ Abstract class with static methods for orchestrating the full automatic update flow. Handles permission checks, version comparison, APK download, and installation.
67
89
 
68
- All methods are static.
90
+ ```typescript
91
+ abstract class AutoUpdate {
92
+ static async run(opt: {
93
+ log: (messageHtml: string) => void;
94
+ serviceClient: ServiceClient;
95
+ }): Promise<void>;
96
+
97
+ static async runByExternalStorage(opt: {
98
+ log: (messageHtml: string) => void;
99
+ dirPath: string;
100
+ }): Promise<void>;
101
+ }
102
+ ```
69
103
 
70
104
  | Method | Signature | Description |
71
105
  |--------|-----------|-------------|
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. |
106
+ | `run` | `static async run(opt: { log: (messageHtml: string) => void; serviceClient: ServiceClient }): Promise<void>` | Download the latest APK from a remote server via `ServiceClient` and install it. Progress is reported through the `log` callback as HTML strings. |
107
+ | `runByExternalStorage` | `static async runByExternalStorage(opt: { log: (messageHtml: string) => void; dirPath: string }): Promise<void>` | Find the latest versioned APK file from an external storage directory and install it. Scans `dirPath` for files named `{semver}.apk`. |
108
+
109
+ ### Parameters for `run`
110
+
111
+ | Field | Type | Description |
112
+ |-------|------|-------------|
113
+ | `log` | `(messageHtml: string) => void` | Callback to display progress/status HTML messages |
114
+ | `serviceClient` | `ServiceClient` | `@simplysm/service-client` instance for server communication |
115
+
116
+ ### Parameters for `runByExternalStorage`
117
+
118
+ | Field | Type | Description |
119
+ |-------|------|-------------|
120
+ | `log` | `(messageHtml: string) => void` | Callback to display progress/status HTML messages |
121
+ | `dirPath` | `string` | Relative path within external storage containing versioned APK files |
74
122
 
75
123
  ## Usage Examples
76
124
 
77
125
  ### Check permissions and install an APK
78
126
 
79
- ```ts
127
+ ```typescript
80
128
  import { ApkInstaller } from "@simplysm/capacitor-plugin-auto-update";
81
129
 
82
130
  const perms = await ApkInstaller.checkPermissions();
131
+ if (!perms.manifest) {
132
+ throw new Error("REQUEST_INSTALL_PACKAGES not declared in AndroidManifest.xml");
133
+ }
83
134
  if (!perms.granted) {
84
135
  await ApkInstaller.requestPermissions();
85
136
  }
@@ -87,9 +138,9 @@ if (!perms.granted) {
87
138
  await ApkInstaller.install("content://com.example.provider/apk/update.apk");
88
139
  ```
89
140
 
90
- ### Auto-update from a server
141
+ ### Auto-update from a remote server
91
142
 
92
- ```ts
143
+ ```typescript
93
144
  import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
94
145
 
95
146
  await AutoUpdate.run({
@@ -102,13 +153,13 @@ await AutoUpdate.run({
102
153
 
103
154
  ### Auto-update from external storage
104
155
 
105
- ```ts
156
+ ```typescript
106
157
  import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
107
158
 
108
159
  await AutoUpdate.runByExternalStorage({
109
160
  log: (messageHtml) => {
110
161
  document.getElementById("status")!.innerHTML = messageHtml;
111
162
  },
112
- dirPath: "/storage/emulated/0/Download/updates",
163
+ dirPath: "MyApp/updates",
113
164
  });
114
165
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/capacitor-plugin-auto-update",
3
- "version": "14.0.4",
3
+ "version": "14.0.6",
4
4
  "description": "심플리즘 패키지 - Capacitor 자동 업데이트 플러그인",
5
5
  "author": "심플리즘",
6
6
  "license": "Apache-2.0",
@@ -19,11 +19,11 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "semver": "^7.7.4",
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"
22
+ "@simplysm/capacitor-plugin-file-system": "14.0.6",
23
+ "@simplysm/core-browser": "14.0.6",
24
+ "@simplysm/core-common": "14.0.6",
25
+ "@simplysm/service-client": "14.0.6",
26
+ "@simplysm/service-common": "14.0.6"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@capacitor/core": "^7.6.1",