native-update 3.1.2 → 3.1.3

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 (202) hide show
  1. package/AI-INTEGRATION-GUIDE.md +15 -10
  2. package/Readme.md +35 -35
  3. package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +88 -12
  4. package/android/src/main/java/com/aoneahsan/nativeupdate/NativeUpdatePlugin.kt +45 -18
  5. package/dist/esm/definitions.d.ts +8 -0
  6. package/dist/esm/plugin.js +16 -2
  7. package/dist/plugin.cjs.js +1 -1
  8. package/dist/plugin.esm.js +1 -1
  9. package/dist/plugin.js +2 -2
  10. package/docs/CHANGELOG.md +73 -0
  11. package/docs/KNOWN_LIMITATIONS.md +2 -2
  12. package/docs/MIGRATION.md +1 -1
  13. package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +64 -8
  14. package/ios/Plugin/NativeUpdatePlugin.swift +39 -13
  15. package/package.json +8 -3
  16. package/docs/AGENTS.md +0 -47
  17. package/docs/APP_REVIEW_GUIDE.md +0 -768
  18. package/docs/BUNDLE_SIGNING.md +0 -277
  19. package/docs/CLAUDE.md +0 -110
  20. package/docs/COMPREHENSIVE_AUDIT_REPORT.md +0 -526
  21. package/docs/DEPLOY_NOTES.md +0 -116
  22. package/docs/EXAMPLE_APPS_SIMPLIFICATION_PLAN.md +0 -384
  23. package/docs/EXAMPLE_APPS_SIMPLIFICATION_TRACKER.md +0 -390
  24. package/docs/LIVE_UPDATES_GUIDE.md +0 -675
  25. package/docs/MANUAL-TASKS.md +0 -30
  26. package/docs/MARKETING_WEBSITE_TRACKER.md +0 -677
  27. package/docs/NATIVE_UPDATES_GUIDE.md +0 -695
  28. package/docs/PACKAGES.md +0 -167
  29. package/docs/PERFORMANCE.md +0 -110
  30. package/docs/PROJECT_COMPLETION_TRACKER.md +0 -411
  31. package/docs/QUICK_START.md +0 -595
  32. package/docs/README.md +0 -130
  33. package/docs/REMAINING_FEATURES.md +0 -192
  34. package/docs/ROADMAP.md +0 -295
  35. package/docs/SECURITY-IF-REPO-PUBLIC.md +0 -232
  36. package/docs/SECURITY.md +0 -356
  37. package/docs/TESTING_REQUIREMENTS.md +0 -201
  38. package/docs/ai-knowledge-base/00-project-profile.md +0 -38
  39. package/docs/ai-knowledge-base/01-features.md +0 -46
  40. package/docs/ai-knowledge-base/02-routes.md +0 -72
  41. package/docs/ai-knowledge-base/03-tech-stack.md +0 -57
  42. package/docs/ai-knowledge-base/README.md +0 -23
  43. package/docs/analytics-tracking.md +0 -37
  44. package/docs/api/API.md +0 -558
  45. package/docs/api/FEATURES.md +0 -414
  46. package/docs/api/app-review-api.md +0 -239
  47. package/docs/api/app-update-api.md +0 -154
  48. package/docs/api/background-update-api.md +0 -170
  49. package/docs/api/events-api.md +0 -323
  50. package/docs/api/live-update-api.md +0 -258
  51. package/docs/archive/MARKETING_WEBSITE_PLAN.md +0 -659
  52. package/docs/background-updates.md +0 -392
  53. package/docs/capacitor-official-plugins.md +0 -46
  54. package/docs/capawesome-plugins.md +0 -29
  55. package/docs/cli-reference.md +0 -321
  56. package/docs/deployment/HOSTINGER_DEPLOY.md +0 -370
  57. package/docs/deployment/PRODUCTION-DEPLOY-CHECKLIST.md +0 -184
  58. package/docs/docs-site/plan.md +0 -201
  59. package/docs/docs-site/scope.md +0 -127
  60. package/docs/docs-site/tracker.json +0 -235
  61. package/docs/error-handling-tracking.md +0 -37
  62. package/docs/examples/advanced-scenarios.md +0 -394
  63. package/docs/examples/android-manifest-example.xml +0 -77
  64. package/docs/examples/basic-usage.md +0 -206
  65. package/docs/examples/node-express-backend-example.md +0 -28
  66. package/docs/examples/react-capacitor-example.md +0 -29
  67. package/docs/features/app-reviews.md +0 -975
  68. package/docs/features/app-updates.md +0 -785
  69. package/docs/features/e2e-full-verification/00-overview.md +0 -99
  70. package/docs/features/e2e-full-verification/00-tracker.json +0 -284
  71. package/docs/features/e2e-full-verification/phase01-backend-schema-fixes.md +0 -183
  72. package/docs/features/e2e-full-verification/phase02-test-auth.md +0 -176
  73. package/docs/features/e2e-full-verification/phase03-api-test-coverage.md +0 -63
  74. package/docs/features/e2e-full-verification/phase04-frontend-package-contract-audit.md +0 -73
  75. package/docs/features/e2e-full-verification/phase05-browser-e2e-matrix.md +0 -69
  76. package/docs/features/e2e-full-verification/phase06-deploy-prod-smoke.md +0 -51
  77. package/docs/features/e2e-full-verification/results/phase01-drift-report.md +0 -50
  78. package/docs/features/e2e-full-verification/results/phase03-coverage-matrix.md +0 -215
  79. package/docs/features/e2e-full-verification/results/phase04-frontend-contract.md +0 -139
  80. package/docs/features/e2e-full-verification/results/phase05-e2e-results.md +0 -99
  81. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-01-dashboard.png +0 -0
  82. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-02-signup.png +0 -0
  83. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-03-settings-persisted.png +0 -0
  84. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-04a-app-created.png +0 -0
  85. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-04b-duplicate-bundle-422.png +0 -0
  86. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-05-plan-limit-403.png +0 -0
  87. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-08a-upload-graceful-fail.png +0 -0
  88. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-08b-builds-list.png +0 -0
  89. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-10-rollout-25pct.png +0 -0
  90. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-11-analytics.png +0 -0
  91. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-12-drive-disconnected.png +0 -0
  92. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-13-pricing.png +0 -0
  93. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-14-isolation-403.png +0 -0
  94. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-15a-admin-overview.png +0 -0
  95. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-15b-regular-user-admin-redirect.png +0 -0
  96. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-16a-delete-dialog.png +0 -0
  97. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-17-mobile-375.png +0 -0
  98. package/docs/features/e2e-full-verification/results/route-list.json +0 -1
  99. package/docs/features/laravel-nova-backend/ASSESSMENT-SUMMARY.md +0 -96
  100. package/docs/features/laravel-nova-backend/IMPLEMENTATION-PLAN.md +0 -504
  101. package/docs/features/laravel-nova-backend/progress-tracker.json +0 -184
  102. package/docs/features/live-updates.md +0 -642
  103. package/docs/features/queues-and-emails/00-overview.md +0 -41
  104. package/docs/features/queues-and-emails/00-tracker.json +0 -99
  105. package/docs/features/queues-and-emails/phase01-foundation.md +0 -15
  106. package/docs/features/queues-and-emails/phase02-queued-jobs.md +0 -19
  107. package/docs/features/queues-and-emails/phase03-transactional-emails.md +0 -16
  108. package/docs/features/queues-and-emails/phase04-quota-ops.md +0 -17
  109. package/docs/features/queues-and-emails/phase05-async-build-processing-DECISION.md +0 -16
  110. package/docs/features/queues-and-emails/phase06-verify-deploy.md +0 -17
  111. package/docs/getting-started/configuration.md +0 -469
  112. package/docs/getting-started/installation.md +0 -300
  113. package/docs/getting-started/quick-start.md +0 -430
  114. package/docs/guides/BACKEND_TEMPLATES_GUIDE.md +0 -183
  115. package/docs/guides/admin-panel.md +0 -268
  116. package/docs/guides/channel-management.md +0 -343
  117. package/docs/guides/dashboard-guide.md +0 -365
  118. package/docs/guides/deployment-guide.md +0 -335
  119. package/docs/guides/end-to-end-workflow.md +0 -491
  120. package/docs/guides/key-management.md +0 -284
  121. package/docs/guides/migration-from-codepush.md +0 -145
  122. package/docs/guides/security-best-practices.md +0 -1057
  123. package/docs/guides/testing-guide.md +0 -346
  124. package/docs/guides/troubleshooting.md +0 -482
  125. package/docs/package-audit.md +0 -41
  126. package/docs/plans/PLANNING_COMPLETE_SUMMARY.md +0 -361
  127. package/docs/plans/TASK_1_ANDROID_EXAMPLE_APP.md +0 -401
  128. package/docs/plans/TASK_2_API_ENDPOINTS.md +0 -856
  129. package/docs/plans/TASK_2_DASHBOARD_UI_UX.md +0 -820
  130. package/docs/plans/TASK_2_DATABASE_SCHEMA.md +0 -704
  131. package/docs/plans/TASK_2_GOOGLE_DRIVE_INTEGRATION.md +0 -646
  132. package/docs/plans/TASK_2_SAAS_ARCHITECTURE.md +0 -587
  133. package/docs/plans/TASK_2_USER_AUTHENTICATION.md +0 -600
  134. package/docs/play-store/ASO-METADATA.md +0 -5
  135. package/docs/play-store/DATA-SAFETY.md +0 -5
  136. package/docs/play-store/DECLARATIONS.md +0 -5
  137. package/docs/play-store/README.md +0 -27
  138. package/docs/play-store/RELEASE-NOTES.md +0 -99
  139. package/docs/play-store/RELEASE-STEPS.md +0 -6
  140. package/docs/play-store/STORE-LISTING.md +0 -7
  141. package/docs/play-store/SUBMISSION-CHECKLIST.md +0 -5
  142. package/docs/production-readiness.md +0 -475
  143. package/docs/project-audit/2026-05-16/00-FINALIZATION-PLAN.md +0 -123
  144. package/docs/project-audit/2026-05-16/01-BATCH-PLAN.md +0 -227
  145. package/docs/project-audit/2026-05-16/02-AUDIT-FINDINGS.md +0 -144
  146. package/docs/project-audit/2026-05-16/sessions/batch-01.md +0 -42
  147. package/docs/project-audit/2026-05-16/sessions/batch-02.md +0 -74
  148. package/docs/project-audit/2026-05-16/sessions/batch-03.md +0 -71
  149. package/docs/project-audit/2026-05-16/sessions/batch-04.md +0 -88
  150. package/docs/project-audit/2026-05-16/sessions/batch-05.md +0 -63
  151. package/docs/project-audit/2026-05-16/sessions/batch-06.md +0 -103
  152. package/docs/project-audit/2026-05-16/sessions/batch-07.md +0 -61
  153. package/docs/project-audit/2026-05-16/sessions/batch-08.md +0 -101
  154. package/docs/project-audit/2026-05-16/sessions/batch-09.md +0 -105
  155. package/docs/project-audit/2026-05-16/sessions/batch-10.md +0 -102
  156. package/docs/project-audit/AUDIT-HISTORY.md +0 -74
  157. package/docs/project-audit/BATCH-PLAN.md +0 -168
  158. package/docs/project-audit/MARKETING-WEBSITE-FINDINGS-2026-05-11.md +0 -73
  159. package/docs/project-audit/PRODUCTION-READINESS-AUDIT-2026-05-08.md +0 -275
  160. package/docs/project-finalization/00-tracker.json +0 -60
  161. package/docs/project-knowledge-base/01-system-overview.md +0 -227
  162. package/docs/project-knowledge-base/02-routes-pages-forms-users.md +0 -352
  163. package/docs/project-knowledge-base/03-tech-stack-modules-services.md +0 -379
  164. package/docs/project-knowledge-base/04-data-models-integrations.md +0 -244
  165. package/docs/project-knowledge-base/05-docs-corpus-inventory.md +0 -256
  166. package/docs/project-knowledge-base/06-operations-testing-legal-content.md +0 -208
  167. package/docs/project-knowledge-base/README.md +0 -103
  168. package/docs/project-profiles/native-update-capacitor-update-platform-project-profile-last-updated-2026-05-19.md +0 -81
  169. package/docs/reports/AUDIT_SUMMARY_2025-12-26.md +0 -203
  170. package/docs/reports/CLAUDE-CODE-COMPLETION-PROMPT.md +0 -403
  171. package/docs/reports/CLAUDE_CODE_PROMPT.md +0 -29
  172. package/docs/reports/CODEBASE_STATUS_REPORT.md +0 -272
  173. package/docs/reports/COMPLETE_VERIFICATION.md +0 -106
  174. package/docs/reports/COMPREHENSIVE-PROJECT-AUDIT-2026-02-24.md +0 -747
  175. package/docs/reports/EVENT_FLOW_VERIFICATION.md +0 -80
  176. package/docs/reports/EXAMPLE_APPS_SIMPLIFICATION_COMPLETE.md +0 -369
  177. package/docs/reports/FINAL_STATUS.md +0 -122
  178. package/docs/reports/FINAL_VERIFICATION_CHECKLIST.md +0 -425
  179. package/docs/reports/MARKETING_WEBSITE_COMPLETE.md +0 -466
  180. package/docs/reports/PACKAGE_COMPLETENESS_REPORT.md +0 -130
  181. package/docs/reports/PRODUCTION_STATUS.md +0 -115
  182. package/docs/reports/PROJECT_RESTRUCTURE_2025-12-27.md +0 -287
  183. package/docs/reports/PROJECT_RESTRUCTURE_FINAL_SUMMARY.md +0 -464
  184. package/docs/reports/PUBLISHING_VERIFICATION.md +0 -144
  185. package/docs/reports/RELEASE_READY_SUMMARY.md +0 -99
  186. package/docs/reports/claude-completion.json +0 -241
  187. package/docs/rules-tracker.md +0 -102
  188. package/docs/security/PRE-LAUNCH-PENTEST-CHECKLIST.md +0 -116
  189. package/docs/security/certificate-pinning.md +0 -122
  190. package/docs/seo-aeo-rules.json +0 -3043
  191. package/docs/social-media-marketing/README.md +0 -81
  192. package/docs/social-media-marketing/posts-batch-01.md +0 -613
  193. package/docs/social-media-marketing/posts-batch-02.md +0 -528
  194. package/docs/social-media-marketing/whatsapp-messages-batch-01.md +0 -458
  195. package/docs/social-media-marketing/whatsapp-status-batch-01.md +0 -355
  196. package/docs/tracking/IMPLEMENTATION_TRACKER.md +0 -303
  197. package/docs/tracking/capacitor-rollout-note-2026-03-01.md +0 -21
  198. package/docs/tracking/completion-tracker-2026-02-24.json +0 -174
  199. package/docs/tracking/finalization-2026-05-16-tracker.json +0 -346
  200. package/docs/tracking/full-audit-tracker.json +0 -121
  201. package/docs/tracking/production-readiness-audit-tracker.json +0 -429
  202. package/docs/tracking/seo-checklist-tracker.json +0 -333
@@ -1,394 +0,0 @@
1
- # Advanced Scenarios
2
-
3
- This guide covers complex use cases and advanced patterns for the Capacitor Native Update plugin.
4
-
5
- ## Delta Updates
6
-
7
- Minimize download sizes by only downloading changed files:
8
-
9
- ```typescript
10
- import { NativeUpdate } from 'native-update';
11
-
12
- async function checkForDeltaUpdate() {
13
- const currentManifest = await NativeUpdate.current();
14
-
15
- const result = await NativeUpdate.sync({
16
- installMode: 'ON_NEXT_RESTART'
17
- });
18
-
19
- if (result.updateAvailable && result.deltaAvailable) {
20
- console.log(`Delta update available: ${result.deltaSize} bytes`);
21
- await downloadDeltaUpdate(result.deltaUrl);
22
- }
23
- }
24
-
25
- async function downloadDeltaUpdate(deltaUrl: string) {
26
- // Download requires url, version, and checksum parameters
27
- const download = await NativeUpdate.download({
28
- url: result.deltaUrl,
29
- version: result.version,
30
- checksum: result.checksum
31
- });
32
-
33
- // Set the bundle as active
34
- await NativeUpdate.set({
35
- bundleId: download.bundleId,
36
- version: download.version,
37
- checksum: download.checksum
38
- });
39
- }
40
- ```
41
-
42
- ## Update Channels
43
-
44
- Manage different release tracks:
45
-
46
- ```typescript
47
- // Configure update channels
48
- enum UpdateChannel {
49
- PRODUCTION = 'production',
50
- BETA = 'beta',
51
- DEVELOPMENT = 'development'
52
- }
53
-
54
- async function setupUpdateChannel(channel: UpdateChannel) {
55
- await NativeUpdate.configure({
56
- updateChannel: channel,
57
- updateUrl: `https://updates.example.com/api/${channel}/check`
58
- });
59
- }
60
-
61
- // Switch channels based on user preference
62
- async function switchToBetaChannel() {
63
- await setupUpdateChannel(UpdateChannel.BETA);
64
-
65
- // Check for updates in the new channel
66
- const result = await NativeUpdate.sync();
67
-
68
- if (result.updateAvailable) {
69
- console.log(`Beta update ${result.version} available`);
70
- }
71
- }
72
- ```
73
-
74
- ## Staged Rollouts
75
-
76
- Implement gradual update deployment:
77
-
78
- ```typescript
79
- async function checkStagedUpdate() {
80
- const deviceId = await getDeviceId();
81
- const rolloutPercentage = hashDeviceId(deviceId) % 100;
82
-
83
- const result = await NativeUpdate.sync({
84
- installMode: 'ON_NEXT_RESTART'
85
- });
86
-
87
- if (result.updateAvailable && result.rolloutPercentage >= rolloutPercentage) {
88
- // Device is eligible for update
89
- await downloadAndInstall(result);
90
- }
91
- }
92
- ```
93
-
94
- ## Background Updates
95
-
96
- Download updates in the background without interrupting users:
97
-
98
- ```typescript
99
- async function setupBackgroundUpdates() {
100
- // Configure background update behavior
101
- await NativeUpdate.configure({
102
- backgroundUpdateMode: 'wifi-only',
103
- autoInstallMode: 'on-restart'
104
- });
105
-
106
- // Configure automatic update checks
107
- await NativeUpdate.configure({
108
- checkInterval: 14400, // 4 hours in seconds
109
- autoCheck: true
110
- });
111
- }
112
-
113
- // Handle background update events
114
- NativeUpdate.addListener('backgroundUpdateNotification', (event) => {
115
- // Notify user that update is ready
116
- if (event.updateAvailable) {
117
- showUpdateNotification({
118
- version: event.version,
119
- type: event.type
120
- });
121
- }
122
- });
123
- ```
124
-
125
- ## Rollback Strategies
126
-
127
- Implement automatic rollback on update failures:
128
-
129
- ```typescript
130
- async function safeUpdate() {
131
- // Get current version info before update
132
- const backup = await NativeUpdate.current();
133
-
134
- try {
135
- // Attempt update
136
- await NativeUpdate.set({
137
- bundleId: 'new-update-id',
138
- version: 'new-version',
139
- checksum: 'bundle-checksum'
140
- });
141
-
142
- // Verify update success
143
- const health = await performHealthCheck();
144
- if (!health.passed) {
145
- throw new Error('Health check failed');
146
- }
147
-
148
- // Notify app is ready with new bundle
149
- await NativeUpdate.notifyAppReady();
150
- } catch (error) {
151
- console.error('Update failed, rolling back:', error);
152
-
153
- // Automatic rollback
154
- await NativeUpdate.reset();
155
-
156
- // Report failure to analytics
157
- reportUpdateFailure(error);
158
- }
159
- }
160
-
161
- async function performHealthCheck(): Promise<{ passed: boolean }> {
162
- // Custom health check logic
163
- try {
164
- // Test critical functionality
165
- await testApiConnection();
166
- await testDatabaseAccess();
167
- await testUIComponents();
168
-
169
- return { passed: true };
170
- } catch {
171
- return { passed: false };
172
- }
173
- }
174
- ```
175
-
176
- ## Multi-Bundle Management
177
-
178
- Handle multiple update bundles for A/B testing:
179
-
180
- ```typescript
181
- interface ABTestConfig {
182
- testId: string;
183
- variants: {
184
- control: string;
185
- treatment: string;
186
- };
187
- }
188
-
189
- async function setupABTest(config: ABTestConfig) {
190
- const variant = await determineVariant(config.testId);
191
-
192
- // Download appropriate bundle
193
- const bundleUrl = variant === 'treatment'
194
- ? config.variants.treatment
195
- : config.variants.control;
196
-
197
- const download = await NativeUpdate.download({
198
- url: bundleUrl,
199
- version: variant,
200
- checksum: 'bundle-checksum' // This should come from server
201
- });
202
-
203
- // Set the bundle as active
204
- await NativeUpdate.set({
205
- bundleId: download.bundleId,
206
- version: download.version,
207
- checksum: download.checksum
208
- });
209
- }
210
- ```
211
-
212
- ## Custom Update UI
213
-
214
- Create sophisticated update experiences:
215
-
216
- ```typescript
217
- class UpdateManager {
218
- private updateState: UpdateState = { status: 'idle' };
219
-
220
- async checkAndPromptUpdate() {
221
- // Check for update
222
- const result = await NativeUpdate.sync();
223
-
224
- if (!result.updateAvailable) return;
225
-
226
- // Show custom update dialog
227
- const userChoice = await this.showUpdateDialog({
228
- version: result.version,
229
- releaseNotes: result.releaseNotes,
230
- size: result.size,
231
- criticalUpdate: result.priority === 'critical'
232
- });
233
-
234
- if (userChoice === 'update') {
235
- await this.performUpdate(result);
236
- } else if (userChoice === 'remind') {
237
- await this.scheduleReminder();
238
- }
239
- }
240
-
241
- private async performUpdate(updateInfo: UpdateInfo) {
242
- this.updateState = { status: 'downloading', progress: 0 };
243
-
244
- // Download with progress tracking
245
- const downloadListener = NativeUpdate.addListener(
246
- 'downloadProgress',
247
- (progress) => {
248
- this.updateState = {
249
- status: 'downloading',
250
- progress: progress.percent
251
- };
252
- this.updateUI();
253
- }
254
- );
255
-
256
- try {
257
- // Download requires url, version, and checksum
258
- const download = await NativeUpdate.download({
259
- url: updateInfo.url,
260
- version: updateInfo.version,
261
- checksum: updateInfo.checksum
262
- });
263
-
264
- this.updateState = { status: 'installing' };
265
- this.updateUI();
266
-
267
- await NativeUpdate.set({
268
- bundleId: download.bundleId,
269
- version: download.version,
270
- checksum: download.checksum
271
- });
272
-
273
- this.updateState = { status: 'ready' };
274
- await this.promptRestart();
275
- } finally {
276
- downloadListener.remove();
277
- }
278
- }
279
- }
280
- ```
281
-
282
- ## Security-Enhanced Updates
283
-
284
- Implement advanced security measures:
285
-
286
- ```typescript
287
- async function secureUpdateCheck() {
288
- // Generate request signature
289
- const timestamp = Date.now();
290
- const nonce = generateNonce();
291
- const signature = await signRequest({
292
- timestamp,
293
- nonce,
294
- version: getCurrentVersion()
295
- });
296
-
297
- const result = await NativeUpdate.sync();
298
-
299
- // Verify response signature
300
- if (!await verifyUpdateSignature(result)) {
301
- throw new Error('Invalid update signature');
302
- }
303
-
304
- return result;
305
- }
306
-
307
- async function downloadWithIntegrityCheck(url: string, expectedHash: string) {
308
- const download = await NativeUpdate.download({
309
- url: url,
310
- version: 'secure-version',
311
- checksum: expectedHash
312
- });
313
-
314
- // Additional verification
315
- const verified = await NativeUpdate.validateUpdate({
316
- bundlePath: download.path,
317
- checksum: download.checksum,
318
- signature: 'bundle-signature'
319
- });
320
-
321
- if (!verified.isValid) {
322
- throw new Error('Bundle verification failed');
323
- }
324
-
325
- return download;
326
- }
327
- ```
328
-
329
- ## Performance Monitoring
330
-
331
- Track update performance and success rates:
332
-
333
- ```typescript
334
- class UpdateMetrics {
335
- async trackUpdateCycle() {
336
- const startTime = Date.now();
337
- const metrics: UpdateMetrics = {
338
- checkStarted: startTime,
339
- downloadStarted: 0,
340
- downloadCompleted: 0,
341
- installStarted: 0,
342
- installCompleted: 0,
343
- errors: []
344
- };
345
-
346
- try {
347
- // Check phase
348
- const result = await NativeUpdate.sync();
349
-
350
- if (!result.updateAvailable) {
351
- metrics.checkCompleted = Date.now();
352
- await this.reportMetrics(metrics);
353
- return;
354
- }
355
-
356
- // Download phase
357
- metrics.downloadStarted = Date.now();
358
- const download = await NativeUpdate.download({
359
- url: result.url,
360
- version: result.version,
361
- checksum: result.checksum
362
- });
363
- metrics.downloadCompleted = Date.now();
364
- metrics.downloadSize = download.size;
365
-
366
- // Install phase
367
- metrics.installStarted = Date.now();
368
- await NativeUpdate.set({
369
- bundleId: download.bundleId,
370
- version: download.version,
371
- checksum: download.checksum
372
- });
373
- metrics.installCompleted = Date.now();
374
-
375
- metrics.success = true;
376
- } catch (error) {
377
- metrics.errors.push({
378
- phase: this.getCurrentPhase(metrics),
379
- error: error.message,
380
- timestamp: Date.now()
381
- });
382
- metrics.success = false;
383
- }
384
-
385
- await this.reportMetrics(metrics);
386
- }
387
- }
388
- ```
389
-
390
- ## Next Steps
391
-
392
- - Review [Basic Usage](https://nativeupdate.aoneahsan.com/docs/examples/basic-usage) for framework-specific implementations
393
- - See the [API Reference](https://nativeupdate.aoneahsan.com/docs/api/live-update-api) for detailed method documentation
394
- - Check [Basic Usage](https://nativeupdate.aoneahsan.com/docs/examples/basic-usage) for simpler examples
@@ -1,77 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!--
3
- EXAMPLE: Complete Android Manifest for apps using native-update plugin
4
- Location: android/app/src/main/AndroidManifest.xml (in YOUR app, not the plugin)
5
-
6
- This example shows the correct placement of all required elements for the
7
- native-update plugin with background update support.
8
- -->
9
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
10
- xmlns:tools="http://schemas.android.com/tools"
11
- package="com.yourcompany.yourapp">
12
-
13
- <!-- Permissions are added automatically by the plugin, but listed here for reference -->
14
- <!-- These permissions allow the plugin to function properly -->
15
- <uses-permission android:name="android.permission.INTERNET" />
16
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
17
- <uses-permission android:name="android.permission.WAKE_LOCK" />
18
- <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
19
- <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
20
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
21
-
22
- <application
23
- android:allowBackup="true"
24
- android:icon="@mipmap/ic_launcher"
25
- android:label="@string/app_name"
26
- android:roundIcon="@mipmap/ic_launcher_round"
27
- android:supportsRtl="true"
28
- android:theme="@style/AppTheme">
29
-
30
- <!-- Your main activity and other components -->
31
- <activity
32
- android:name=".MainActivity"
33
- android:label="@string/app_name"
34
- android:theme="@style/AppTheme.NoActionBar"
35
- android:launchMode="singleTask"
36
- android:exported="true">
37
- <intent-filter>
38
- <action android:name="android.intent.action.MAIN" />
39
- <category android:name="android.intent.category.LAUNCHER" />
40
- </intent-filter>
41
- </activity>
42
-
43
- <!-- ============================================= -->
44
- <!-- REQUIRED FOR NATIVE-UPDATE BACKGROUND UPDATES -->
45
- <!-- ============================================= -->
46
-
47
- <!-- WorkManager Foreground Service -->
48
- <!-- This service is REQUIRED for background downloads to work -->
49
- <!-- Without it: Downloads will fail with ServiceNotFoundException -->
50
- <!-- Purpose: Keeps downloads running when app is in background -->
51
- <service
52
- android:name="androidx.work.impl.foreground.SystemForegroundService"
53
- android:foregroundServiceType="dataSync"
54
- tools:node="merge" />
55
-
56
- <!-- Notification Action Receiver -->
57
- <!-- This receiver is REQUIRED for notification buttons to work -->
58
- <!-- Without it: Update notifications will show but buttons won't work -->
59
- <!-- Purpose: Handles "Update Now", "Update Later", and "Dismiss" actions -->
60
- <receiver
61
- android:name="com.aoneahsan.nativeupdate.NotificationActionReceiver"
62
- android:exported="false">
63
- <intent-filter>
64
- <!-- Action triggered when user taps "Update Now" -->
65
- <action android:name="com.aoneahsan.nativeupdate.UPDATE_NOW" />
66
- <!-- Action triggered when user taps "Update Later" -->
67
- <action android:name="com.aoneahsan.nativeupdate.UPDATE_LATER" />
68
- <!-- Action triggered when user dismisses the notification -->
69
- <action android:name="com.aoneahsan.nativeupdate.DISMISS" />
70
- </intent-filter>
71
- </receiver>
72
-
73
- <!-- Other app components like providers, services, etc. -->
74
-
75
- </application>
76
-
77
- </manifest>
@@ -1,206 +0,0 @@
1
- # Basic Usage Examples
2
-
3
- This guide demonstrates basic usage patterns for the Capacitor Native Update plugin.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- yarn add native-update
9
- npx cap sync
10
- ```
11
-
12
- ## Simple Live Update Check
13
-
14
- ```typescript
15
- import { NativeUpdate } from 'native-update';
16
-
17
- // Check for updates on app startup
18
- async function checkForUpdates() {
19
- try {
20
- const result = await NativeUpdate.sync({
21
- updateUrl: 'https://your-update-server.com/api/check'
22
- });
23
-
24
- if (result.status === 'UPDATE_AVAILABLE') {
25
- console.log(`Update available: ${result.bundle?.version}`);
26
- // Update will be downloaded and installed automatically
27
- } else if (result.status === 'UPDATE_INSTALLED') {
28
- // Reload the app to apply the update
29
- await NativeUpdate.reload();
30
- }
31
- } catch (error) {
32
- console.error('Update check failed:', error);
33
- }
34
- }
35
-
36
- async function downloadAndInstall(version: string) {
37
- // Download a specific version
38
- const download = await NativeUpdate.download({
39
- version: version
40
- });
41
-
42
- // Set the downloaded bundle as active
43
- await NativeUpdate.set({
44
- bundleId: download.bundleId,
45
- version: download.version,
46
- checksum: download.checksum
47
- });
48
-
49
- // Reload the app with new bundle
50
- await NativeUpdate.reload();
51
- }
52
- ```
53
-
54
- ## Basic App Store Update Check
55
-
56
- ```typescript
57
- // Check if a native app update is available
58
- async function checkAppStoreUpdate() {
59
- const result = await NativeUpdate.getAppUpdateInfo();
60
-
61
- if (result.updateAvailable) {
62
- // Show update prompt to user
63
- const shouldUpdate = confirm(
64
- `Version ${result.availableVersion} is available. Update now?`
65
- );
66
-
67
- if (shouldUpdate) {
68
- // Open app store for update
69
- await NativeUpdate.openAppStore();
70
- }
71
- }
72
- }
73
- ```
74
-
75
- ## Simple App Review Request
76
-
77
- ```typescript
78
- // Request app review after positive user action
79
- async function requestReview() {
80
- try {
81
- const result = await NativeUpdate.requestReview();
82
-
83
- if (result.displayed) {
84
- console.log('Review dialog was shown');
85
- // Track that review was requested
86
- }
87
- } catch (error) {
88
- console.error('Could not request review:', error);
89
- }
90
- }
91
-
92
- // Example: Request review after successful task completion
93
- async function onTaskCompleted() {
94
- // Your task logic here
95
-
96
- // Check if it's a good time to ask for review
97
- const completedTasks = getCompletedTaskCount();
98
- if (completedTasks === 5) {
99
- await requestReview();
100
- }
101
- }
102
- ```
103
-
104
- ## Configuration Options
105
-
106
- ```typescript
107
- // Option 1: Direct configuration (auto-initializes if not already initialized)
108
- await NativeUpdate.configure({
109
- config: {
110
- // Live update settings
111
- autoUpdate: true,
112
- updateCheckInterval: 3600000, // 1 hour
113
- updateChannel: 'production',
114
-
115
- // Security settings
116
- enableSignatureVerification: true,
117
- publicKey: 'your-public-key',
118
-
119
- // App review settings
120
- minimumDaysSinceInstall: 3,
121
- minimumDaysSinceLastPrompt: 30
122
- }
123
- });
124
-
125
- // Option 2: Explicit initialization (if you need more control)
126
- await NativeUpdate.initialize({
127
- config: {
128
- autoUpdate: true,
129
- updateChannel: 'production'
130
- }
131
- });
132
-
133
- // Later, you can update configuration
134
- await NativeUpdate.configure({
135
- config: {
136
- updateChannel: 'staging',
137
- autoUpdate: false
138
- }
139
- });
140
- ```
141
-
142
- ## Error Handling
143
-
144
- ```typescript
145
- // Comprehensive error handling
146
- async function safeUpdateCheck() {
147
- try {
148
- const result = await NativeUpdate.sync({
149
- updateUrl: 'https://your-update-server.com/api/check'
150
- });
151
-
152
- if (result.status === 'UPDATE_AVAILABLE' || result.status === 'UPDATE_INSTALLED') {
153
- await handleUpdate(result);
154
- }
155
- } catch (error) {
156
- if (error.code === 'NETWORK_ERROR') {
157
- console.log('No internet connection');
158
- } else if (error.code === 'INVALID_RESPONSE') {
159
- console.error('Invalid server response');
160
- } else {
161
- console.error('Unexpected error:', error);
162
- }
163
- }
164
- }
165
- ```
166
-
167
- ## Event Listeners
168
-
169
- ```typescript
170
- // Set up event listeners
171
- function setupUpdateListeners() {
172
- // Update state changes
173
- NativeUpdate.addListener('updateStateChanged', (event) => {
174
- console.log('Update state:', event.status);
175
- if (event.status === 'READY') {
176
- // Update has been applied successfully
177
- console.log('Update ready to use');
178
- }
179
- });
180
-
181
- // Download progress
182
- NativeUpdate.addListener('downloadProgress', (progress) => {
183
- console.log(`Download progress: ${progress.percent}%`);
184
- console.log(`Speed: ${progress.bytesPerSecond} bytes/s`);
185
- });
186
-
187
- // Background update notifications
188
- NativeUpdate.addListener('backgroundUpdateNotification', (event) => {
189
- if (event.updateAvailable) {
190
- console.log(`Background update available: ${event.version}`);
191
- }
192
- });
193
- }
194
-
195
- // Clean up listeners when done
196
- function cleanup() {
197
- NativeUpdate.removeAllListeners();
198
- }
199
- ```
200
-
201
- ## Next Steps
202
-
203
- - See [Advanced Scenarios](https://nativeupdate.aoneahsan.com/docs/examples/advanced-scenarios) for more complex use cases
204
- - Read the [Live Update API Reference](https://nativeupdate.aoneahsan.com/docs/api/live-update-api) for complete live update methods
205
- - Read the [App Update API Reference](https://nativeupdate.aoneahsan.com/docs/api/app-update-api) for native update methods
206
- - Read the [App Review API Reference](https://nativeupdate.aoneahsan.com/docs/api/app-review-api) for review request methods
@@ -1,28 +0,0 @@
1
- # Node.js + Express Backend Example
2
-
3
- This example shows a self-hosted backend for serving update manifests and bundles using Node.js + Express.
4
-
5
- ## What It Covers
6
-
7
- - Bundle upload endpoint
8
- - Manifest responses for client update checks
9
- - Local file-based storage flow for development
10
-
11
- ## Recommended Setup Flow
12
-
13
- 1. Understand server requirements:
14
- https://nativeupdate.aoneahsan.com/docs/server-requirements
15
- 2. Review backend patterns:
16
- https://nativeupdate.aoneahsan.com/docs/guides/BACKEND_TEMPLATES_GUIDE
17
- 3. Apply security requirements before production:
18
- https://nativeupdate.aoneahsan.com/docs/BUNDLE_SIGNING
19
- https://nativeupdate.aoneahsan.com/docs/guides/security-best-practices
20
-
21
- ## Related Docs
22
-
23
- - Deployment Guide:
24
- https://nativeupdate.aoneahsan.com/docs/guides/deployment-guide
25
- - CLI Reference:
26
- https://nativeupdate.aoneahsan.com/docs/cli-reference
27
- - Troubleshooting:
28
- https://nativeupdate.aoneahsan.com/docs/guides/troubleshooting