@simplysm/capacitor-plugin-auto-update 12.16.30 → 12.16.31
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 +157 -0
- package/package.json +6 -6
package/README.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# @simplysm/capacitor-plugin-auto-update
|
|
2
|
+
|
|
3
|
+
Capacitor 7 plugin for auto-updating Android apps via APK installation. Provides two update strategies: server-based updates through `SdServiceClient` and external storage-based updates from a local directory.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @simplysm/capacitor-plugin-auto-update
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Peer Dependencies
|
|
12
|
+
|
|
13
|
+
- `@capacitor/core` ^7.0.0
|
|
14
|
+
- `@simplysm/capacitor-plugin-file-system`
|
|
15
|
+
|
|
16
|
+
### Android Setup
|
|
17
|
+
|
|
18
|
+
Register the plugin in your `MainActivity`:
|
|
19
|
+
|
|
20
|
+
```java
|
|
21
|
+
import kr.co.simplysm.capacitor.apkinstaller.ApkInstallerPlugin;
|
|
22
|
+
|
|
23
|
+
public class MainActivity extends BridgeActivity {
|
|
24
|
+
@Override
|
|
25
|
+
protected void onCreate(Bundle savedInstanceState) {
|
|
26
|
+
registerPlugin(ApkInstallerPlugin.class);
|
|
27
|
+
super.onCreate(savedInstanceState);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The plugin declares `REQUEST_INSTALL_PACKAGES` permission in its `AndroidManifest.xml`.
|
|
33
|
+
|
|
34
|
+
## API
|
|
35
|
+
|
|
36
|
+
### `AutoUpdate`
|
|
37
|
+
|
|
38
|
+
Abstract utility class that orchestrates the full update flow: version check, download, permission handling, and APK installation.
|
|
39
|
+
|
|
40
|
+
#### `AutoUpdate.runAsync(opt)`
|
|
41
|
+
|
|
42
|
+
Performs a server-based auto-update. Connects to the server via `SdServiceClient`, compares the current app version (`process.env["SD_VERSION"]`) against the server's latest version, downloads the APK if outdated, and triggers installation.
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
await AutoUpdate.runAsync({
|
|
46
|
+
log: (messageHtml: string) => {
|
|
47
|
+
// Display progress/status HTML to the user
|
|
48
|
+
},
|
|
49
|
+
serviceClient: sdServiceClient,
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
| Parameter | Type | Description |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `opt.log` | `(messageHtml: string) => void` | Callback to display status messages (may contain HTML) |
|
|
56
|
+
| `opt.serviceClient` | `SdServiceClient` | Connected service client instance. The server must implement `ISdAutoUpdateService`. |
|
|
57
|
+
|
|
58
|
+
#### `AutoUpdate.runByExternalStorageAsync(opt)`
|
|
59
|
+
|
|
60
|
+
Performs an update from APK files stored in external storage. Scans the specified directory for APK files named by semver version (e.g., `1.2.3.apk`), selects the highest version, and installs it if newer than the current version.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
await AutoUpdate.runByExternalStorageAsync({
|
|
64
|
+
log: (messageHtml: string) => {
|
|
65
|
+
// Display progress/status HTML to the user
|
|
66
|
+
},
|
|
67
|
+
dirPath: "MyApp/updates",
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
| Parameter | Type | Description |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| `opt.log` | `(messageHtml: string) => void` | Callback to display status messages (may contain HTML) |
|
|
74
|
+
| `opt.dirPath` | `string` | Relative path within external storage containing versioned APK files |
|
|
75
|
+
|
|
76
|
+
### `ApkInstaller`
|
|
77
|
+
|
|
78
|
+
Low-level static API wrapping the native Capacitor plugin for APK installation and permission management. On web, all methods resolve with no-op behavior.
|
|
79
|
+
|
|
80
|
+
#### `ApkInstaller.hasPermissionManifest()`
|
|
81
|
+
|
|
82
|
+
Checks whether `REQUEST_INSTALL_PACKAGES` is declared in the app's `AndroidManifest.xml`.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
const declared: boolean = await ApkInstaller.hasPermissionManifest();
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### `ApkInstaller.hasPermission()`
|
|
89
|
+
|
|
90
|
+
Checks whether the app currently has permission to install unknown apps (Android 8.0+). Returns `true` on older versions.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
const granted: boolean = await ApkInstaller.hasPermission();
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### `ApkInstaller.requestPermission()`
|
|
97
|
+
|
|
98
|
+
Opens the system settings screen for managing unknown app install sources (Android 8.0+).
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
await ApkInstaller.requestPermission();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### `ApkInstaller.install(apkUri)`
|
|
105
|
+
|
|
106
|
+
Triggers APK installation via `ACTION_VIEW` intent.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
await ApkInstaller.install(apkUri);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
| Parameter | Type | Description |
|
|
113
|
+
|---|---|---|
|
|
114
|
+
| `apkUri` | `string` | `content://` URI of the APK file (FileProvider URI) |
|
|
115
|
+
|
|
116
|
+
#### `ApkInstaller.getVersionInfo()`
|
|
117
|
+
|
|
118
|
+
Returns the current app's version name and version code.
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
const info: IVersionInfo = await ApkInstaller.getVersionInfo();
|
|
122
|
+
// info.versionName - e.g., "1.2.3"
|
|
123
|
+
// info.versionCode - e.g., "10"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Interfaces
|
|
127
|
+
|
|
128
|
+
#### `IVersionInfo`
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
interface IVersionInfo {
|
|
132
|
+
versionName: string;
|
|
133
|
+
versionCode: string;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### `IApkInstallerPlugin`
|
|
138
|
+
|
|
139
|
+
Low-level Capacitor plugin interface. Use `ApkInstaller` static methods instead of calling this directly.
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
interface IApkInstallerPlugin {
|
|
143
|
+
install(options: { uri: string }): Promise<void>;
|
|
144
|
+
hasPermission(): Promise<{ granted: boolean }>;
|
|
145
|
+
requestPermission(): Promise<void>;
|
|
146
|
+
hasPermissionManifest(): Promise<{ declared: boolean }>;
|
|
147
|
+
getVersionInfo(): Promise<IVersionInfo>;
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Platform Support
|
|
152
|
+
|
|
153
|
+
| Platform | Behavior |
|
|
154
|
+
|---|---|
|
|
155
|
+
| Android | Full APK installation with permission management |
|
|
156
|
+
| Web | No-op stubs (permission checks return `true`, install shows an alert) |
|
|
157
|
+
| iOS | Not supported |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/capacitor-plugin-auto-update",
|
|
3
|
-
"version": "12.16.
|
|
3
|
+
"version": "12.16.31",
|
|
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.
|
|
22
|
-
"@simplysm/sd-service-client": "12.16.
|
|
23
|
-
"@simplysm/sd-service-common": "12.16.
|
|
21
|
+
"@simplysm/sd-core-common": "12.16.31",
|
|
22
|
+
"@simplysm/sd-service-client": "12.16.31",
|
|
23
|
+
"@simplysm/sd-service-common": "12.16.31",
|
|
24
24
|
"semver": "^7.7.4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@capacitor/core": "^7.5.0",
|
|
28
|
-
"@simplysm/capacitor-plugin-file-system": "12.16.
|
|
28
|
+
"@simplysm/capacitor-plugin-file-system": "12.16.31",
|
|
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.
|
|
33
|
+
"@simplysm/capacitor-plugin-file-system": "12.16.31"
|
|
34
34
|
}
|
|
35
35
|
}
|