native-update 1.0.0
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/CapacitorNativeUpdate.podspec +18 -0
- package/LICENSE +21 -0
- package/Readme.md +451 -0
- package/android/build.gradle +92 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/android/gradle.properties +17 -0
- package/android/proguard-rules.pro +29 -0
- package/android/settings.gradle +2 -0
- package/android/src/main/AndroidManifest.xml +34 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/AppReviewPlugin.kt +153 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/AppUpdatePlugin.kt +275 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundNotificationManager.kt +390 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateManager.kt +46 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdatePlugin.kt +333 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateWorker.kt +251 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/CapacitorNativeUpdatePlugin.kt +265 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +526 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/NotificationActionReceiver.kt +99 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/SecurityManager.kt +249 -0
- package/dist/esm/__tests__/bundle-manager.test.d.ts +1 -0
- package/dist/esm/__tests__/bundle-manager.test.js +123 -0
- package/dist/esm/__tests__/bundle-manager.test.js.map +1 -0
- package/dist/esm/__tests__/config.test.d.ts +1 -0
- package/dist/esm/__tests__/config.test.js +69 -0
- package/dist/esm/__tests__/config.test.js.map +1 -0
- package/dist/esm/__tests__/integration.test.d.ts +1 -0
- package/dist/esm/__tests__/integration.test.js +78 -0
- package/dist/esm/__tests__/integration.test.js.map +1 -0
- package/dist/esm/__tests__/security.test.d.ts +1 -0
- package/dist/esm/__tests__/security.test.js +54 -0
- package/dist/esm/__tests__/security.test.js.map +1 -0
- package/dist/esm/__tests__/version-manager.test.d.ts +1 -0
- package/dist/esm/__tests__/version-manager.test.js +45 -0
- package/dist/esm/__tests__/version-manager.test.js.map +1 -0
- package/dist/esm/app-review/app-review-manager.d.ts +24 -0
- package/dist/esm/app-review/app-review-manager.js +195 -0
- package/dist/esm/app-review/app-review-manager.js.map +1 -0
- package/dist/esm/app-review/index.d.ts +5 -0
- package/dist/esm/app-review/index.js +6 -0
- package/dist/esm/app-review/index.js.map +1 -0
- package/dist/esm/app-review/platform-review-handler.d.ts +20 -0
- package/dist/esm/app-review/platform-review-handler.js +138 -0
- package/dist/esm/app-review/platform-review-handler.js.map +1 -0
- package/dist/esm/app-review/review-conditions-checker.d.ts +22 -0
- package/dist/esm/app-review/review-conditions-checker.js +155 -0
- package/dist/esm/app-review/review-conditions-checker.js.map +1 -0
- package/dist/esm/app-review/review-rate-limiter.d.ts +23 -0
- package/dist/esm/app-review/review-rate-limiter.js +164 -0
- package/dist/esm/app-review/review-rate-limiter.js.map +1 -0
- package/dist/esm/app-review/types.d.ts +41 -0
- package/dist/esm/app-review/types.js +2 -0
- package/dist/esm/app-review/types.js.map +1 -0
- package/dist/esm/app-update/app-update-checker.d.ts +13 -0
- package/dist/esm/app-update/app-update-checker.js +104 -0
- package/dist/esm/app-update/app-update-checker.js.map +1 -0
- package/dist/esm/app-update/app-update-installer.d.ts +19 -0
- package/dist/esm/app-update/app-update-installer.js +123 -0
- package/dist/esm/app-update/app-update-installer.js.map +1 -0
- package/dist/esm/app-update/app-update-manager.d.ts +28 -0
- package/dist/esm/app-update/app-update-manager.js +199 -0
- package/dist/esm/app-update/app-update-manager.js.map +1 -0
- package/dist/esm/app-update/app-update-notifier.d.ts +14 -0
- package/dist/esm/app-update/app-update-notifier.js +100 -0
- package/dist/esm/app-update/app-update-notifier.js.map +1 -0
- package/dist/esm/app-update/index.d.ts +6 -0
- package/dist/esm/app-update/index.js +7 -0
- package/dist/esm/app-update/index.js.map +1 -0
- package/dist/esm/app-update/platform-app-update.d.ts +19 -0
- package/dist/esm/app-update/platform-app-update.js +129 -0
- package/dist/esm/app-update/platform-app-update.js.map +1 -0
- package/dist/esm/app-update/types.d.ts +58 -0
- package/dist/esm/app-update/types.js +12 -0
- package/dist/esm/app-update/types.js.map +1 -0
- package/dist/esm/background-update/background-scheduler.d.ts +17 -0
- package/dist/esm/background-update/background-scheduler.js +195 -0
- package/dist/esm/background-update/background-scheduler.js.map +1 -0
- package/dist/esm/background-update/index.d.ts +3 -0
- package/dist/esm/background-update/index.js +3 -0
- package/dist/esm/background-update/index.js.map +1 -0
- package/dist/esm/background-update/notification-manager.d.ts +29 -0
- package/dist/esm/background-update/notification-manager.js +89 -0
- package/dist/esm/background-update/notification-manager.js.map +1 -0
- package/dist/esm/core/analytics.d.ts +70 -0
- package/dist/esm/core/analytics.js +137 -0
- package/dist/esm/core/analytics.js.map +1 -0
- package/dist/esm/core/cache-manager.d.ts +72 -0
- package/dist/esm/core/cache-manager.js +275 -0
- package/dist/esm/core/cache-manager.js.map +1 -0
- package/dist/esm/core/config.d.ts +48 -0
- package/dist/esm/core/config.js +83 -0
- package/dist/esm/core/config.js.map +1 -0
- package/dist/esm/core/errors.d.ts +51 -0
- package/dist/esm/core/errors.js +80 -0
- package/dist/esm/core/errors.js.map +1 -0
- package/dist/esm/core/logger.d.ts +21 -0
- package/dist/esm/core/logger.js +109 -0
- package/dist/esm/core/logger.js.map +1 -0
- package/dist/esm/core/performance.d.ts +53 -0
- package/dist/esm/core/performance.js +140 -0
- package/dist/esm/core/performance.js.map +1 -0
- package/dist/esm/core/plugin-manager.d.ts +66 -0
- package/dist/esm/core/plugin-manager.js +148 -0
- package/dist/esm/core/plugin-manager.js.map +1 -0
- package/dist/esm/core/security.d.ts +93 -0
- package/dist/esm/core/security.js +315 -0
- package/dist/esm/core/security.js.map +1 -0
- package/dist/esm/definitions.d.ts +639 -0
- package/dist/esm/definitions.js +103 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/live-update/bundle-manager.d.ts +94 -0
- package/dist/esm/live-update/bundle-manager.js +310 -0
- package/dist/esm/live-update/bundle-manager.js.map +1 -0
- package/dist/esm/live-update/certificate-pinning.d.ts +38 -0
- package/dist/esm/live-update/certificate-pinning.js +78 -0
- package/dist/esm/live-update/certificate-pinning.js.map +1 -0
- package/dist/esm/live-update/download-manager.d.ts +67 -0
- package/dist/esm/live-update/download-manager.js +319 -0
- package/dist/esm/live-update/download-manager.js.map +1 -0
- package/dist/esm/live-update/update-manager.d.ts +52 -0
- package/dist/esm/live-update/update-manager.js +294 -0
- package/dist/esm/live-update/update-manager.js.map +1 -0
- package/dist/esm/live-update/version-manager.d.ts +84 -0
- package/dist/esm/live-update/version-manager.js +335 -0
- package/dist/esm/live-update/version-manager.js.map +1 -0
- package/dist/esm/plugin.d.ts +6 -0
- package/dist/esm/plugin.js +283 -0
- package/dist/esm/plugin.js.map +1 -0
- package/dist/esm/security/crypto.d.ts +25 -0
- package/dist/esm/security/crypto.js +70 -0
- package/dist/esm/security/crypto.js.map +1 -0
- package/dist/esm/security/validator.d.ts +60 -0
- package/dist/esm/security/validator.js +143 -0
- package/dist/esm/security/validator.js.map +1 -0
- package/dist/esm/web.d.ts +74 -0
- package/dist/esm/web.js +595 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +2 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.esm.js +2 -0
- package/dist/plugin.esm.js.map +1 -0
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -0
- package/docs/APP_REVIEW_GUIDE.md +768 -0
- package/docs/BUNDLE_SIGNING.md +264 -0
- package/docs/LIVE_UPDATES_GUIDE.md +650 -0
- package/docs/MIGRATION.md +192 -0
- package/docs/NATIVE_UPDATES_GUIDE.md +694 -0
- package/docs/QUICK_START.md +606 -0
- package/docs/README.md +111 -0
- package/docs/REMAINING_FEATURES.md +139 -0
- package/docs/api/app-review-api.md +259 -0
- package/docs/api/app-update-api.md +238 -0
- package/docs/api/events-api.md +451 -0
- package/docs/api/live-update-api.md +265 -0
- package/docs/background-updates.md +392 -0
- package/docs/examples/advanced-scenarios.md +410 -0
- package/docs/examples/basic-usage.md +185 -0
- package/docs/features/app-reviews.md +975 -0
- package/docs/features/app-updates.md +785 -0
- package/docs/features/live-updates.md +633 -0
- package/docs/getting-started/configuration.md +468 -0
- package/docs/getting-started/installation.md +209 -0
- package/docs/getting-started/quick-start.md +379 -0
- package/docs/guides/deployment-guide.md +333 -0
- package/docs/guides/migration-from-codepush.md +142 -0
- package/docs/guides/security-best-practices.md +1057 -0
- package/docs/guides/testing-guide.md +373 -0
- package/docs/production-readiness.md +478 -0
- package/docs/security/certificate-pinning.md +122 -0
- package/docs/server-requirements.md +147 -0
- package/ios/Plugin/AppReview/AppReviewPlugin.swift +158 -0
- package/ios/Plugin/AppUpdate/AppUpdatePlugin.swift +234 -0
- package/ios/Plugin/BackgroundUpdate/BackgroundNotificationManager.swift +329 -0
- package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +396 -0
- package/ios/Plugin/CapacitorNativeUpdatePlugin.m +45 -0
- package/ios/Plugin/CapacitorNativeUpdatePlugin.swift +190 -0
- package/ios/Plugin/Info.plist +43 -0
- package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +689 -0
- package/ios/Plugin/LiveUpdate/WebViewConfiguration.swift +45 -0
- package/ios/Plugin/Security/SecurityManager.swift +289 -0
- package/package.json +90 -0
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
# Configuration Guide
|
|
2
|
+
|
|
3
|
+
> **⚠️ Backend Server Required**
|
|
4
|
+
>
|
|
5
|
+
> All configuration options in this guide assume you have already built and deployed:
|
|
6
|
+
> - A complete update server with all required API endpoints
|
|
7
|
+
> - Bundle generation and signing infrastructure
|
|
8
|
+
> - CDN or storage solution for bundle distribution
|
|
9
|
+
> - Security infrastructure for signatures and certificates
|
|
10
|
+
>
|
|
11
|
+
> **Without these backend components, the plugin will not function regardless of configuration.**
|
|
12
|
+
|
|
13
|
+
This guide covers all configuration options available in Capacitor Native Update. The plugin is highly configurable to meet various deployment scenarios and security requirements.
|
|
14
|
+
|
|
15
|
+
## Configuration Overview
|
|
16
|
+
|
|
17
|
+
The plugin is configured using the `configure()` method with an `UpdateConfig` object:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
await CapacitorNativeUpdate.configure({
|
|
21
|
+
liveUpdate: {
|
|
22
|
+
/* Live update settings */
|
|
23
|
+
},
|
|
24
|
+
appUpdate: {
|
|
25
|
+
/* App store update settings */
|
|
26
|
+
},
|
|
27
|
+
appReview: {
|
|
28
|
+
/* Review request settings */
|
|
29
|
+
},
|
|
30
|
+
security: {
|
|
31
|
+
/* Security settings */
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Live Update Configuration
|
|
37
|
+
|
|
38
|
+
Configure how your app handles over-the-air updates.
|
|
39
|
+
|
|
40
|
+
### Basic Configuration
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
liveUpdate: {
|
|
44
|
+
// Required: Your application identifier
|
|
45
|
+
appId: 'com.yourcompany.app',
|
|
46
|
+
|
|
47
|
+
// Required: Your update server URL
|
|
48
|
+
serverUrl: 'https://updates.yourserver.com',
|
|
49
|
+
|
|
50
|
+
// Update channel (default: 'production')
|
|
51
|
+
channel: 'production',
|
|
52
|
+
|
|
53
|
+
// Enable automatic update checks (default: true)
|
|
54
|
+
autoUpdate: true,
|
|
55
|
+
|
|
56
|
+
// Update strategy
|
|
57
|
+
updateStrategy: 'IMMEDIATE' // or 'BACKGROUND' or 'MANUAL'
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Advanced Configuration
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
liveUpdate: {
|
|
65
|
+
appId: 'com.yourcompany.app',
|
|
66
|
+
serverUrl: 'https://updates.yourserver.com',
|
|
67
|
+
channel: 'production',
|
|
68
|
+
|
|
69
|
+
// Security
|
|
70
|
+
publicKey: 'YOUR_RSA_PUBLIC_KEY',
|
|
71
|
+
requireSignature: true,
|
|
72
|
+
checksumAlgorithm: 'SHA-256', // or 'SHA-512'
|
|
73
|
+
|
|
74
|
+
// Update behavior
|
|
75
|
+
updateStrategy: 'BACKGROUND',
|
|
76
|
+
mandatoryInstallMode: 'IMMEDIATE',
|
|
77
|
+
optionalInstallMode: 'ON_NEXT_RESTART',
|
|
78
|
+
|
|
79
|
+
// Update checks
|
|
80
|
+
autoUpdate: true,
|
|
81
|
+
checkInterval: 3600000, // Check every hour (in ms)
|
|
82
|
+
|
|
83
|
+
// Restrictions
|
|
84
|
+
allowEmulator: false, // Disable updates on emulators
|
|
85
|
+
maxBundleSize: 50 * 1024 * 1024, // 50MB limit
|
|
86
|
+
|
|
87
|
+
// Network
|
|
88
|
+
allowedHosts: [
|
|
89
|
+
'updates.yourserver.com',
|
|
90
|
+
'cdn.yourserver.com'
|
|
91
|
+
],
|
|
92
|
+
|
|
93
|
+
// Retry configuration
|
|
94
|
+
maxRetries: 3,
|
|
95
|
+
retryDelay: 1000, // 1 second
|
|
96
|
+
timeout: 30000 // 30 seconds
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Configuration Options Explained
|
|
101
|
+
|
|
102
|
+
#### Update Strategies
|
|
103
|
+
|
|
104
|
+
- **`IMMEDIATE`**: Downloads and installs updates immediately when found
|
|
105
|
+
- **`BACKGROUND`**: Downloads in background, installs based on install mode
|
|
106
|
+
- **`MANUAL`**: Full control - you decide when to download and install
|
|
107
|
+
|
|
108
|
+
#### Install Modes
|
|
109
|
+
|
|
110
|
+
- **`IMMEDIATE`**: Installs and restarts immediately
|
|
111
|
+
- **`ON_NEXT_RESTART`**: Installs on next app restart
|
|
112
|
+
- **`ON_NEXT_RESUME`**: Installs when app resumes from background
|
|
113
|
+
|
|
114
|
+
#### Security Options
|
|
115
|
+
|
|
116
|
+
- **`publicKey`**: RSA public key for signature verification
|
|
117
|
+
- **`requireSignature`**: Enforce bundle signature validation
|
|
118
|
+
- **`checksumAlgorithm`**: Hash algorithm for integrity checks
|
|
119
|
+
|
|
120
|
+
## App Update Configuration
|
|
121
|
+
|
|
122
|
+
Configure native app store update behavior.
|
|
123
|
+
|
|
124
|
+
### Basic Configuration
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
appUpdate: {
|
|
128
|
+
// Check for updates on app start
|
|
129
|
+
checkOnAppStart: true,
|
|
130
|
+
|
|
131
|
+
// Minimum required version
|
|
132
|
+
minimumVersion: '2.0.0',
|
|
133
|
+
|
|
134
|
+
// Update priority (0-5, where 5 is highest)
|
|
135
|
+
updatePriority: 3
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Advanced Configuration
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
appUpdate: {
|
|
143
|
+
checkOnAppStart: true,
|
|
144
|
+
minimumVersion: '2.0.0',
|
|
145
|
+
updatePriority: 4,
|
|
146
|
+
|
|
147
|
+
// Custom store URLs
|
|
148
|
+
storeUrl: {
|
|
149
|
+
android: 'https://play.google.com/store/apps/details?id=com.yourapp',
|
|
150
|
+
ios: 'https://apps.apple.com/app/id123456789'
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
// Allow version downgrades (not recommended)
|
|
154
|
+
allowDowngrade: false,
|
|
155
|
+
|
|
156
|
+
// Force update if below minimum version
|
|
157
|
+
forceUpdateBelow: '1.5.0',
|
|
158
|
+
|
|
159
|
+
// Check interval for app updates (ms)
|
|
160
|
+
checkInterval: 86400000 // Once per day
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Update Priority Levels
|
|
165
|
+
|
|
166
|
+
| Priority | Behavior |
|
|
167
|
+
| -------- | --------------------------------------- |
|
|
168
|
+
| 0-2 | Low - Optional update, can be dismissed |
|
|
169
|
+
| 3 | Medium - Recommended update |
|
|
170
|
+
| 4 | High - Strongly recommended |
|
|
171
|
+
| 5 | Critical - Immediate update required |
|
|
172
|
+
|
|
173
|
+
## App Review Configuration
|
|
174
|
+
|
|
175
|
+
Configure when and how to request user reviews.
|
|
176
|
+
|
|
177
|
+
### Basic Configuration
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
appReview: {
|
|
181
|
+
// Days since install before first prompt
|
|
182
|
+
minimumDaysSinceInstall: 7,
|
|
183
|
+
|
|
184
|
+
// Days between review prompts
|
|
185
|
+
minimumDaysSinceLastPrompt: 60,
|
|
186
|
+
|
|
187
|
+
// App launches before eligible
|
|
188
|
+
minimumLaunchCount: 3
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Advanced Configuration
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
appReview: {
|
|
196
|
+
minimumDaysSinceInstall: 7,
|
|
197
|
+
minimumDaysSinceLastPrompt: 60,
|
|
198
|
+
minimumLaunchCount: 5,
|
|
199
|
+
|
|
200
|
+
// Significant events before eligible
|
|
201
|
+
minimumSignificantEvents: 3,
|
|
202
|
+
|
|
203
|
+
// Custom trigger events
|
|
204
|
+
customTriggers: [
|
|
205
|
+
'purchase_completed',
|
|
206
|
+
'level_completed',
|
|
207
|
+
'task_finished'
|
|
208
|
+
],
|
|
209
|
+
|
|
210
|
+
// Debug mode - bypass all restrictions
|
|
211
|
+
debugMode: false,
|
|
212
|
+
|
|
213
|
+
// Maximum prompts per version
|
|
214
|
+
maxPromptsPerVersion: 2,
|
|
215
|
+
|
|
216
|
+
// Require positive events
|
|
217
|
+
requirePositiveEvents: true
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Security Configuration
|
|
222
|
+
|
|
223
|
+
Configure security features for all update operations.
|
|
224
|
+
|
|
225
|
+
### Comprehensive Security Setup
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
security: {
|
|
229
|
+
// Force HTTPS for all URLs
|
|
230
|
+
enforceHttps: true,
|
|
231
|
+
|
|
232
|
+
// Certificate pinning
|
|
233
|
+
certificatePinning: {
|
|
234
|
+
enabled: true,
|
|
235
|
+
certificates: [
|
|
236
|
+
'sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=',
|
|
237
|
+
'sha256/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB='
|
|
238
|
+
],
|
|
239
|
+
includeSubdomains: true,
|
|
240
|
+
maxAge: 31536000 // 1 year
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
// Input validation
|
|
244
|
+
validateInputs: true,
|
|
245
|
+
|
|
246
|
+
// Secure storage for sensitive data
|
|
247
|
+
secureStorage: true,
|
|
248
|
+
|
|
249
|
+
// Security event logging
|
|
250
|
+
logSecurityEvents: true,
|
|
251
|
+
|
|
252
|
+
// Content Security Policy
|
|
253
|
+
contentSecurityPolicy: {
|
|
254
|
+
enabled: true,
|
|
255
|
+
policy: "default-src 'self'; script-src 'self' 'unsafe-inline';"
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Environment-Specific Configuration
|
|
261
|
+
|
|
262
|
+
### Development Environment
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
const isDevelopment = process.env.NODE_ENV === 'development';
|
|
266
|
+
|
|
267
|
+
await CapacitorNativeUpdate.configure({
|
|
268
|
+
liveUpdate: {
|
|
269
|
+
appId: 'com.yourcompany.app.dev',
|
|
270
|
+
serverUrl: isDevelopment
|
|
271
|
+
? 'http://localhost:3000'
|
|
272
|
+
: 'https://updates.yourserver.com',
|
|
273
|
+
channel: isDevelopment ? 'development' : 'production',
|
|
274
|
+
allowEmulator: isDevelopment,
|
|
275
|
+
requireSignature: !isDevelopment,
|
|
276
|
+
},
|
|
277
|
+
appReview: {
|
|
278
|
+
debugMode: isDevelopment,
|
|
279
|
+
},
|
|
280
|
+
security: {
|
|
281
|
+
enforceHttps: !isDevelopment,
|
|
282
|
+
},
|
|
283
|
+
});
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Multiple Environments
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
interface Environment {
|
|
290
|
+
name: string;
|
|
291
|
+
serverUrl: string;
|
|
292
|
+
channel: string;
|
|
293
|
+
publicKey?: string;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const environments: Record<string, Environment> = {
|
|
297
|
+
development: {
|
|
298
|
+
name: 'Development',
|
|
299
|
+
serverUrl: 'http://localhost:3000',
|
|
300
|
+
channel: 'development',
|
|
301
|
+
},
|
|
302
|
+
staging: {
|
|
303
|
+
name: 'Staging',
|
|
304
|
+
serverUrl: 'https://staging-updates.yourserver.com',
|
|
305
|
+
channel: 'staging',
|
|
306
|
+
publicKey: 'STAGING_PUBLIC_KEY',
|
|
307
|
+
},
|
|
308
|
+
production: {
|
|
309
|
+
name: 'Production',
|
|
310
|
+
serverUrl: 'https://updates.yourserver.com',
|
|
311
|
+
channel: 'production',
|
|
312
|
+
publicKey: 'PRODUCTION_PUBLIC_KEY',
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const currentEnv = environments[process.env.APP_ENV || 'production'];
|
|
317
|
+
|
|
318
|
+
await CapacitorNativeUpdate.configure({
|
|
319
|
+
liveUpdate: {
|
|
320
|
+
appId: 'com.yourcompany.app',
|
|
321
|
+
serverUrl: currentEnv.serverUrl,
|
|
322
|
+
channel: currentEnv.channel,
|
|
323
|
+
publicKey: currentEnv.publicKey,
|
|
324
|
+
requireSignature: !!currentEnv.publicKey,
|
|
325
|
+
},
|
|
326
|
+
});
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## Dynamic Configuration
|
|
330
|
+
|
|
331
|
+
### Runtime Configuration Updates
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
// Change update channel
|
|
335
|
+
await CapacitorNativeUpdate.LiveUpdate.setChannel('beta');
|
|
336
|
+
|
|
337
|
+
// Change server URL
|
|
338
|
+
await CapacitorNativeUpdate.LiveUpdate.setUpdateUrl('https://new-server.com');
|
|
339
|
+
|
|
340
|
+
// Update security settings
|
|
341
|
+
await CapacitorNativeUpdate.Security.updateConfig({
|
|
342
|
+
enforceHttps: true,
|
|
343
|
+
requireSignature: true,
|
|
344
|
+
});
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Configuration from Remote Source
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
async function loadRemoteConfig() {
|
|
351
|
+
try {
|
|
352
|
+
// Fetch configuration from your backend
|
|
353
|
+
const response = await fetch('https://api.yourserver.com/app-config');
|
|
354
|
+
const remoteConfig = await response.json();
|
|
355
|
+
|
|
356
|
+
// Apply remote configuration
|
|
357
|
+
await CapacitorNativeUpdate.configure({
|
|
358
|
+
liveUpdate: {
|
|
359
|
+
appId: remoteConfig.appId,
|
|
360
|
+
serverUrl: remoteConfig.updateServer,
|
|
361
|
+
channel: remoteConfig.channel,
|
|
362
|
+
updateStrategy: remoteConfig.updateStrategy,
|
|
363
|
+
publicKey: remoteConfig.publicKey,
|
|
364
|
+
},
|
|
365
|
+
appUpdate: {
|
|
366
|
+
minimumVersion: remoteConfig.minimumVersion,
|
|
367
|
+
updatePriority: remoteConfig.updatePriority,
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
} catch (error) {
|
|
371
|
+
// Fall back to default configuration
|
|
372
|
+
console.error('Failed to load remote config:', error);
|
|
373
|
+
await loadDefaultConfig();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## Configuration Best Practices
|
|
379
|
+
|
|
380
|
+
### 1. Security First
|
|
381
|
+
|
|
382
|
+
Always enable security features in production:
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
// Production security configuration
|
|
386
|
+
const productionConfig = {
|
|
387
|
+
liveUpdate: {
|
|
388
|
+
requireSignature: true,
|
|
389
|
+
checksumAlgorithm: 'SHA-512',
|
|
390
|
+
publicKey: process.env.UPDATE_PUBLIC_KEY,
|
|
391
|
+
},
|
|
392
|
+
security: {
|
|
393
|
+
enforceHttps: true,
|
|
394
|
+
certificatePinning: { enabled: true },
|
|
395
|
+
validateInputs: true,
|
|
396
|
+
secureStorage: true,
|
|
397
|
+
},
|
|
398
|
+
};
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### 2. Progressive Rollout
|
|
402
|
+
|
|
403
|
+
Use channels for staged deployments:
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
// Rollout stages
|
|
407
|
+
const rolloutConfig = {
|
|
408
|
+
liveUpdate: {
|
|
409
|
+
channel: getUserRolloutChannel(), // 'alpha', 'beta', 'production'
|
|
410
|
+
updateStrategy: isEarlyAdopter() ? 'IMMEDIATE' : 'BACKGROUND',
|
|
411
|
+
},
|
|
412
|
+
};
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
### 3. Error Recovery
|
|
416
|
+
|
|
417
|
+
Configure retry and fallback behavior:
|
|
418
|
+
|
|
419
|
+
```typescript
|
|
420
|
+
const resilientConfig = {
|
|
421
|
+
liveUpdate: {
|
|
422
|
+
maxRetries: 3,
|
|
423
|
+
retryDelay: 2000,
|
|
424
|
+
timeout: 30000,
|
|
425
|
+
fallbackUrl: 'https://backup-updates.yourserver.com',
|
|
426
|
+
},
|
|
427
|
+
};
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### 4. Performance Optimization
|
|
431
|
+
|
|
432
|
+
Configure for optimal performance:
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
const performanceConfig = {
|
|
436
|
+
liveUpdate: {
|
|
437
|
+
updateStrategy: 'BACKGROUND',
|
|
438
|
+
checkInterval: 3600000, // Check hourly
|
|
439
|
+
maxBundleSize: 20 * 1024 * 1024, // 20MB limit
|
|
440
|
+
installMode: 'ON_NEXT_RESTART', // Non-disruptive
|
|
441
|
+
},
|
|
442
|
+
};
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
## Validation
|
|
446
|
+
|
|
447
|
+
The plugin validates all configuration options and will throw descriptive errors for invalid configurations:
|
|
448
|
+
|
|
449
|
+
```typescript
|
|
450
|
+
try {
|
|
451
|
+
await CapacitorNativeUpdate.configure(config);
|
|
452
|
+
} catch (error) {
|
|
453
|
+
if (error.code === 'INVALID_CONFIG') {
|
|
454
|
+
console.error('Configuration error:', error.message);
|
|
455
|
+
// Handle specific configuration errors
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
## Next Steps
|
|
461
|
+
|
|
462
|
+
- Implement [Security Best Practices](../guides/security-best-practices.md)
|
|
463
|
+
- Set up your [Update Server](../examples/server-setup.md)
|
|
464
|
+
- Explore [Advanced Features](../features/live-updates.md)
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
Made with ❤️ by Ahsan Mahmood
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Installation Guide
|
|
2
|
+
|
|
3
|
+
> **⚠️ WARNING: What's NOT Included**
|
|
4
|
+
>
|
|
5
|
+
> Installing this plugin gives you **client-side functionality only**. You will NOT get:
|
|
6
|
+
>
|
|
7
|
+
> - ❌ An update server (you must build your own)
|
|
8
|
+
> - ❌ Bundle generation tools (requires custom CI/CD setup)
|
|
9
|
+
> - ❌ Ready-to-use backend API (implement from scratch)
|
|
10
|
+
> - ❌ Admin dashboard or management UI
|
|
11
|
+
> - ❌ Bundle hosting or CDN setup
|
|
12
|
+
> - ❌ Security infrastructure (certificates, signing keys)
|
|
13
|
+
> - ❌ Analytics or monitoring systems
|
|
14
|
+
>
|
|
15
|
+
> **Before proceeding**, ensure you have the technical resources to build the complete backend infrastructure. This plugin is only useful if you can implement the extensive server-side requirements.
|
|
16
|
+
|
|
17
|
+
This guide will walk you through installing and setting up the Capacitor Native Update plugin in your project.
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
Before installing the plugin, ensure you have:
|
|
22
|
+
|
|
23
|
+
- **Capacitor 7.0.0** or higher installed in your project
|
|
24
|
+
- **Node.js 18+** and npm/yarn installed
|
|
25
|
+
- **iOS Requirements**: Xcode 14+ and iOS 13.0+ deployment target
|
|
26
|
+
- **Android Requirements**: Android Studio and minimum SDK 21 (Android 5.0)
|
|
27
|
+
|
|
28
|
+
## Installation Steps
|
|
29
|
+
|
|
30
|
+
### 1. Install the Plugin
|
|
31
|
+
|
|
32
|
+
Using npm:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install native-update
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Using yarn:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
yarn add native-update
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 2. Sync Native Projects
|
|
45
|
+
|
|
46
|
+
After installation, sync the plugin with your native projects:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx cap sync
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This command will:
|
|
53
|
+
|
|
54
|
+
- Copy the web assets to native projects
|
|
55
|
+
- Install the native dependencies
|
|
56
|
+
- Update native project configurations
|
|
57
|
+
|
|
58
|
+
### 3. Platform-Specific Setup
|
|
59
|
+
|
|
60
|
+
#### iOS Setup
|
|
61
|
+
|
|
62
|
+
1. Open your iOS project in Xcode:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npx cap open ios
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
2. Ensure your deployment target is set to iOS 13.0 or higher:
|
|
69
|
+
- Select your project in Xcode
|
|
70
|
+
- Go to the "General" tab
|
|
71
|
+
- Set "Minimum Deployments" to iOS 13.0
|
|
72
|
+
|
|
73
|
+
3. Add required permissions to `Info.plist` (if not already present):
|
|
74
|
+
```xml
|
|
75
|
+
<key>NSAppTransportSecurity</key>
|
|
76
|
+
<dict>
|
|
77
|
+
<key>NSAllowsArbitraryLoads</key>
|
|
78
|
+
<false/>
|
|
79
|
+
</dict>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Android Setup
|
|
83
|
+
|
|
84
|
+
1. Open your Android project:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npx cap open android
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
2. Ensure your `minSdkVersion` is 21 or higher in `android/variables.gradle`:
|
|
91
|
+
|
|
92
|
+
```gradle
|
|
93
|
+
ext {
|
|
94
|
+
minSdkVersion = 21
|
|
95
|
+
targetSdkVersion = 34
|
|
96
|
+
compileSdkVersion = 34
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
3. The plugin automatically adds required permissions to the manifest:
|
|
101
|
+
- `INTERNET` - For downloading updates
|
|
102
|
+
- `ACCESS_NETWORK_STATE` - For checking network availability
|
|
103
|
+
|
|
104
|
+
#### Web Setup
|
|
105
|
+
|
|
106
|
+
No additional setup is required for web platform. The plugin provides fallback implementations for all features.
|
|
107
|
+
|
|
108
|
+
### 4. Initialize the Plugin
|
|
109
|
+
|
|
110
|
+
In your app's initialization code (e.g., `main.ts`, `app.component.ts`, or `App.jsx`):
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { CapacitorNativeUpdate } from 'native-update';
|
|
114
|
+
|
|
115
|
+
// Basic initialization
|
|
116
|
+
await CapacitorNativeUpdate.configure({
|
|
117
|
+
liveUpdate: {
|
|
118
|
+
appId: 'your-app-id',
|
|
119
|
+
serverUrl: 'https://your-update-server.com',
|
|
120
|
+
channel: 'production',
|
|
121
|
+
autoUpdate: true,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Verification
|
|
127
|
+
|
|
128
|
+
To verify the installation:
|
|
129
|
+
|
|
130
|
+
1. Build and run your app:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npx cap run ios
|
|
134
|
+
# or
|
|
135
|
+
npx cap run android
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
2. Check the console logs for initialization messages
|
|
139
|
+
|
|
140
|
+
3. Test basic functionality:
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
// Get current bundle info
|
|
144
|
+
const currentBundle = await CapacitorNativeUpdate.LiveUpdate.current();
|
|
145
|
+
console.log('Current bundle:', currentBundle);
|
|
146
|
+
|
|
147
|
+
// Check for updates
|
|
148
|
+
const latest = await CapacitorNativeUpdate.LiveUpdate.getLatest();
|
|
149
|
+
console.log('Latest version available:', latest);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## TypeScript Support
|
|
153
|
+
|
|
154
|
+
The plugin includes comprehensive TypeScript definitions. Your IDE should provide full autocompletion and type checking.
|
|
155
|
+
|
|
156
|
+
To import types:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import type {
|
|
160
|
+
UpdateConfig,
|
|
161
|
+
BundleInfo,
|
|
162
|
+
SyncResult,
|
|
163
|
+
} from 'native-update';
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Troubleshooting Installation
|
|
167
|
+
|
|
168
|
+
### Common Issues
|
|
169
|
+
|
|
170
|
+
1. **"Module not found" error**
|
|
171
|
+
- Run `npm install` or `yarn install` again
|
|
172
|
+
- Delete `node_modules` and reinstall
|
|
173
|
+
- Ensure you've run `npx cap sync`
|
|
174
|
+
|
|
175
|
+
2. **iOS build errors**
|
|
176
|
+
- Clean build folder: `Product > Clean Build Folder` in Xcode
|
|
177
|
+
- Delete `DerivedData` folder
|
|
178
|
+
- Run `pod install` in the `ios/App` directory
|
|
179
|
+
|
|
180
|
+
3. **Android build errors**
|
|
181
|
+
- Clean and rebuild: `./gradlew clean` in Android Studio
|
|
182
|
+
- Sync project with Gradle files
|
|
183
|
+
- Ensure Android Gradle Plugin is up to date
|
|
184
|
+
|
|
185
|
+
4. **TypeScript errors**
|
|
186
|
+
- Update TypeScript to 4.0 or higher
|
|
187
|
+
- Restart your TypeScript language server
|
|
188
|
+
- Check `tsconfig.json` includes the plugin types
|
|
189
|
+
|
|
190
|
+
## Next Steps
|
|
191
|
+
|
|
192
|
+
After successful installation:
|
|
193
|
+
|
|
194
|
+
1. Read the [Quick Start Guide](./quick-start.md) for basic usage
|
|
195
|
+
2. Configure the plugin with your [update server settings](./configuration.md)
|
|
196
|
+
3. Implement [security best practices](../guides/security-best-practices.md)
|
|
197
|
+
4. Set up your [update server](../examples/server-setup.md)
|
|
198
|
+
|
|
199
|
+
## Support
|
|
200
|
+
|
|
201
|
+
If you encounter any issues during installation:
|
|
202
|
+
|
|
203
|
+
- Check our [Troubleshooting Guide](../guides/troubleshooting.md)
|
|
204
|
+
- Search existing [GitHub Issues](https://github.com/aoneahsan/native-update/issues)
|
|
205
|
+
- Create a new issue with detailed information about your setup
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
Made with ❤️ by Ahsan Mahmood
|