native-update 3.1.1 → 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 (203) hide show
  1. package/AI-INTEGRATION-GUIDE.md +98 -63
  2. package/Readme.md +89 -120
  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/cli/package.json +2 -2
  6. package/dist/esm/definitions.d.ts +8 -0
  7. package/dist/esm/plugin.js +16 -2
  8. package/dist/plugin.cjs.js +1 -1
  9. package/dist/plugin.esm.js +1 -1
  10. package/dist/plugin.js +2 -2
  11. package/docs/CHANGELOG.md +108 -0
  12. package/docs/KNOWN_LIMITATIONS.md +2 -2
  13. package/docs/MIGRATION.md +1 -1
  14. package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +64 -8
  15. package/ios/Plugin/NativeUpdatePlugin.swift +39 -13
  16. package/package.json +8 -3
  17. package/docs/AGENTS.md +0 -47
  18. package/docs/APP_REVIEW_GUIDE.md +0 -768
  19. package/docs/BUNDLE_SIGNING.md +0 -277
  20. package/docs/CLAUDE.md +0 -110
  21. package/docs/COMPREHENSIVE_AUDIT_REPORT.md +0 -526
  22. package/docs/DEPLOY_NOTES.md +0 -117
  23. package/docs/EXAMPLE_APPS_SIMPLIFICATION_PLAN.md +0 -384
  24. package/docs/EXAMPLE_APPS_SIMPLIFICATION_TRACKER.md +0 -390
  25. package/docs/LIVE_UPDATES_GUIDE.md +0 -675
  26. package/docs/MANUAL-TASKS.md +0 -30
  27. package/docs/MARKETING_WEBSITE_TRACKER.md +0 -677
  28. package/docs/NATIVE_UPDATES_GUIDE.md +0 -695
  29. package/docs/PACKAGES.md +0 -167
  30. package/docs/PERFORMANCE.md +0 -110
  31. package/docs/PROJECT_COMPLETION_TRACKER.md +0 -411
  32. package/docs/QUICK_START.md +0 -595
  33. package/docs/README.md +0 -130
  34. package/docs/REMAINING_FEATURES.md +0 -192
  35. package/docs/ROADMAP.md +0 -295
  36. package/docs/SECURITY-IF-REPO-PUBLIC.md +0 -232
  37. package/docs/SECURITY.md +0 -356
  38. package/docs/TESTING_REQUIREMENTS.md +0 -201
  39. package/docs/ai-knowledge-base/00-project-profile.md +0 -38
  40. package/docs/ai-knowledge-base/01-features.md +0 -46
  41. package/docs/ai-knowledge-base/02-routes.md +0 -72
  42. package/docs/ai-knowledge-base/03-tech-stack.md +0 -57
  43. package/docs/ai-knowledge-base/README.md +0 -23
  44. package/docs/analytics-tracking.md +0 -37
  45. package/docs/api/API.md +0 -558
  46. package/docs/api/FEATURES.md +0 -414
  47. package/docs/api/app-review-api.md +0 -239
  48. package/docs/api/app-update-api.md +0 -154
  49. package/docs/api/background-update-api.md +0 -170
  50. package/docs/api/events-api.md +0 -323
  51. package/docs/api/live-update-api.md +0 -258
  52. package/docs/archive/MARKETING_WEBSITE_PLAN.md +0 -659
  53. package/docs/background-updates.md +0 -392
  54. package/docs/capacitor-official-plugins.md +0 -46
  55. package/docs/capawesome-plugins.md +0 -29
  56. package/docs/cli-reference.md +0 -321
  57. package/docs/deployment/HOSTINGER_DEPLOY.md +0 -370
  58. package/docs/deployment/PRODUCTION-DEPLOY-CHECKLIST.md +0 -184
  59. package/docs/docs-site/plan.md +0 -201
  60. package/docs/docs-site/scope.md +0 -127
  61. package/docs/docs-site/tracker.json +0 -235
  62. package/docs/error-handling-tracking.md +0 -37
  63. package/docs/examples/advanced-scenarios.md +0 -394
  64. package/docs/examples/android-manifest-example.xml +0 -77
  65. package/docs/examples/basic-usage.md +0 -206
  66. package/docs/examples/node-express-backend-example.md +0 -28
  67. package/docs/examples/react-capacitor-example.md +0 -29
  68. package/docs/features/app-reviews.md +0 -975
  69. package/docs/features/app-updates.md +0 -785
  70. package/docs/features/e2e-full-verification/00-overview.md +0 -99
  71. package/docs/features/e2e-full-verification/00-tracker.json +0 -284
  72. package/docs/features/e2e-full-verification/phase01-backend-schema-fixes.md +0 -183
  73. package/docs/features/e2e-full-verification/phase02-test-auth.md +0 -176
  74. package/docs/features/e2e-full-verification/phase03-api-test-coverage.md +0 -63
  75. package/docs/features/e2e-full-verification/phase04-frontend-package-contract-audit.md +0 -73
  76. package/docs/features/e2e-full-verification/phase05-browser-e2e-matrix.md +0 -69
  77. package/docs/features/e2e-full-verification/phase06-deploy-prod-smoke.md +0 -51
  78. package/docs/features/e2e-full-verification/results/phase01-drift-report.md +0 -50
  79. package/docs/features/e2e-full-verification/results/phase03-coverage-matrix.md +0 -215
  80. package/docs/features/e2e-full-verification/results/phase04-frontend-contract.md +0 -139
  81. package/docs/features/e2e-full-verification/results/phase05-e2e-results.md +0 -99
  82. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-01-dashboard.png +0 -0
  83. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-02-signup.png +0 -0
  84. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-03-settings-persisted.png +0 -0
  85. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-04a-app-created.png +0 -0
  86. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-04b-duplicate-bundle-422.png +0 -0
  87. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-05-plan-limit-403.png +0 -0
  88. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-08a-upload-graceful-fail.png +0 -0
  89. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-08b-builds-list.png +0 -0
  90. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-10-rollout-25pct.png +0 -0
  91. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-11-analytics.png +0 -0
  92. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-12-drive-disconnected.png +0 -0
  93. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-13-pricing.png +0 -0
  94. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-14-isolation-403.png +0 -0
  95. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-15a-admin-overview.png +0 -0
  96. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-15b-regular-user-admin-redirect.png +0 -0
  97. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-16a-delete-dialog.png +0 -0
  98. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-17-mobile-375.png +0 -0
  99. package/docs/features/e2e-full-verification/results/route-list.json +0 -1
  100. package/docs/features/laravel-nova-backend/ASSESSMENT-SUMMARY.md +0 -96
  101. package/docs/features/laravel-nova-backend/IMPLEMENTATION-PLAN.md +0 -504
  102. package/docs/features/laravel-nova-backend/progress-tracker.json +0 -184
  103. package/docs/features/live-updates.md +0 -642
  104. package/docs/features/queues-and-emails/00-overview.md +0 -41
  105. package/docs/features/queues-and-emails/00-tracker.json +0 -99
  106. package/docs/features/queues-and-emails/phase01-foundation.md +0 -15
  107. package/docs/features/queues-and-emails/phase02-queued-jobs.md +0 -19
  108. package/docs/features/queues-and-emails/phase03-transactional-emails.md +0 -16
  109. package/docs/features/queues-and-emails/phase04-quota-ops.md +0 -17
  110. package/docs/features/queues-and-emails/phase05-async-build-processing-DECISION.md +0 -16
  111. package/docs/features/queues-and-emails/phase06-verify-deploy.md +0 -17
  112. package/docs/getting-started/configuration.md +0 -469
  113. package/docs/getting-started/installation.md +0 -300
  114. package/docs/getting-started/quick-start.md +0 -430
  115. package/docs/guides/BACKEND_TEMPLATES_GUIDE.md +0 -183
  116. package/docs/guides/admin-panel.md +0 -268
  117. package/docs/guides/channel-management.md +0 -343
  118. package/docs/guides/dashboard-guide.md +0 -365
  119. package/docs/guides/deployment-guide.md +0 -335
  120. package/docs/guides/end-to-end-workflow.md +0 -491
  121. package/docs/guides/key-management.md +0 -284
  122. package/docs/guides/migration-from-codepush.md +0 -145
  123. package/docs/guides/security-best-practices.md +0 -1057
  124. package/docs/guides/testing-guide.md +0 -346
  125. package/docs/guides/troubleshooting.md +0 -482
  126. package/docs/package-audit.md +0 -41
  127. package/docs/plans/PLANNING_COMPLETE_SUMMARY.md +0 -361
  128. package/docs/plans/TASK_1_ANDROID_EXAMPLE_APP.md +0 -401
  129. package/docs/plans/TASK_2_API_ENDPOINTS.md +0 -856
  130. package/docs/plans/TASK_2_DASHBOARD_UI_UX.md +0 -820
  131. package/docs/plans/TASK_2_DATABASE_SCHEMA.md +0 -704
  132. package/docs/plans/TASK_2_GOOGLE_DRIVE_INTEGRATION.md +0 -646
  133. package/docs/plans/TASK_2_SAAS_ARCHITECTURE.md +0 -587
  134. package/docs/plans/TASK_2_USER_AUTHENTICATION.md +0 -600
  135. package/docs/play-store/ASO-METADATA.md +0 -5
  136. package/docs/play-store/DATA-SAFETY.md +0 -5
  137. package/docs/play-store/DECLARATIONS.md +0 -5
  138. package/docs/play-store/README.md +0 -27
  139. package/docs/play-store/RELEASE-NOTES.md +0 -99
  140. package/docs/play-store/RELEASE-STEPS.md +0 -6
  141. package/docs/play-store/STORE-LISTING.md +0 -7
  142. package/docs/play-store/SUBMISSION-CHECKLIST.md +0 -5
  143. package/docs/production-readiness.md +0 -475
  144. package/docs/project-audit/2026-05-16/00-FINALIZATION-PLAN.md +0 -123
  145. package/docs/project-audit/2026-05-16/01-BATCH-PLAN.md +0 -227
  146. package/docs/project-audit/2026-05-16/02-AUDIT-FINDINGS.md +0 -144
  147. package/docs/project-audit/2026-05-16/sessions/batch-01.md +0 -42
  148. package/docs/project-audit/2026-05-16/sessions/batch-02.md +0 -74
  149. package/docs/project-audit/2026-05-16/sessions/batch-03.md +0 -71
  150. package/docs/project-audit/2026-05-16/sessions/batch-04.md +0 -88
  151. package/docs/project-audit/2026-05-16/sessions/batch-05.md +0 -63
  152. package/docs/project-audit/2026-05-16/sessions/batch-06.md +0 -103
  153. package/docs/project-audit/2026-05-16/sessions/batch-07.md +0 -61
  154. package/docs/project-audit/2026-05-16/sessions/batch-08.md +0 -101
  155. package/docs/project-audit/2026-05-16/sessions/batch-09.md +0 -105
  156. package/docs/project-audit/2026-05-16/sessions/batch-10.md +0 -102
  157. package/docs/project-audit/AUDIT-HISTORY.md +0 -74
  158. package/docs/project-audit/BATCH-PLAN.md +0 -168
  159. package/docs/project-audit/MARKETING-WEBSITE-FINDINGS-2026-05-11.md +0 -73
  160. package/docs/project-audit/PRODUCTION-READINESS-AUDIT-2026-05-08.md +0 -275
  161. package/docs/project-finalization/00-tracker.json +0 -60
  162. package/docs/project-knowledge-base/01-system-overview.md +0 -227
  163. package/docs/project-knowledge-base/02-routes-pages-forms-users.md +0 -352
  164. package/docs/project-knowledge-base/03-tech-stack-modules-services.md +0 -379
  165. package/docs/project-knowledge-base/04-data-models-integrations.md +0 -244
  166. package/docs/project-knowledge-base/05-docs-corpus-inventory.md +0 -256
  167. package/docs/project-knowledge-base/06-operations-testing-legal-content.md +0 -208
  168. package/docs/project-knowledge-base/README.md +0 -103
  169. package/docs/project-profiles/native-update-capacitor-update-platform-project-profile-last-updated-2026-05-19.md +0 -81
  170. package/docs/reports/AUDIT_SUMMARY_2025-12-26.md +0 -203
  171. package/docs/reports/CLAUDE-CODE-COMPLETION-PROMPT.md +0 -403
  172. package/docs/reports/CLAUDE_CODE_PROMPT.md +0 -29
  173. package/docs/reports/CODEBASE_STATUS_REPORT.md +0 -272
  174. package/docs/reports/COMPLETE_VERIFICATION.md +0 -106
  175. package/docs/reports/COMPREHENSIVE-PROJECT-AUDIT-2026-02-24.md +0 -747
  176. package/docs/reports/EVENT_FLOW_VERIFICATION.md +0 -80
  177. package/docs/reports/EXAMPLE_APPS_SIMPLIFICATION_COMPLETE.md +0 -369
  178. package/docs/reports/FINAL_STATUS.md +0 -122
  179. package/docs/reports/FINAL_VERIFICATION_CHECKLIST.md +0 -425
  180. package/docs/reports/MARKETING_WEBSITE_COMPLETE.md +0 -466
  181. package/docs/reports/PACKAGE_COMPLETENESS_REPORT.md +0 -130
  182. package/docs/reports/PRODUCTION_STATUS.md +0 -115
  183. package/docs/reports/PROJECT_RESTRUCTURE_2025-12-27.md +0 -287
  184. package/docs/reports/PROJECT_RESTRUCTURE_FINAL_SUMMARY.md +0 -464
  185. package/docs/reports/PUBLISHING_VERIFICATION.md +0 -144
  186. package/docs/reports/RELEASE_READY_SUMMARY.md +0 -99
  187. package/docs/reports/claude-completion.json +0 -241
  188. package/docs/rules-tracker.md +0 -102
  189. package/docs/security/PRE-LAUNCH-PENTEST-CHECKLIST.md +0 -116
  190. package/docs/security/certificate-pinning.md +0 -122
  191. package/docs/seo-aeo-rules.json +0 -3043
  192. package/docs/social-media-marketing/README.md +0 -81
  193. package/docs/social-media-marketing/posts-batch-01.md +0 -613
  194. package/docs/social-media-marketing/posts-batch-02.md +0 -528
  195. package/docs/social-media-marketing/whatsapp-messages-batch-01.md +0 -458
  196. package/docs/social-media-marketing/whatsapp-status-batch-01.md +0 -355
  197. package/docs/tracking/IMPLEMENTATION_TRACKER.md +0 -303
  198. package/docs/tracking/capacitor-rollout-note-2026-03-01.md +0 -21
  199. package/docs/tracking/completion-tracker-2026-02-24.json +0 -174
  200. package/docs/tracking/finalization-2026-05-16-tracker.json +0 -346
  201. package/docs/tracking/full-audit-tracker.json +0 -121
  202. package/docs/tracking/production-readiness-audit-tracker.json +0 -429
  203. package/docs/tracking/seo-checklist-tracker.json +0 -333
@@ -1,430 +0,0 @@
1
- # Quick Start Guide
2
-
3
- > **⚠️ IMPORTANT: Backend Infrastructure Required**
4
- >
5
- > This plugin is a **client-side SDK only** and requires significant backend infrastructure to function:
6
- >
7
- > - **Update Server**: You must build and host your own server to manage and serve update bundles
8
- > - **Bundle Generation**: You need a CI/CD pipeline to create, sign, and deploy update bundles
9
- > - **Security Infrastructure**: Implement bundle signing, verification, and secure distribution
10
- > - **Version Management**: Handle versioning, channels, and rollback mechanisms
11
- > - **Analytics & Monitoring**: Track update success rates and handle failures
12
- >
13
- > **This is NOT a complete solution** - it's a foundation that requires substantial additional development. See our [Server Requirements](https://nativeupdate.aoneahsan.com/docs/server-requirements) guide for detailed backend implementation requirements.
14
-
15
- Get up and running with Capacitor Native Update in just a few minutes! This guide covers the most common use cases.
16
-
17
- ## Basic Setup
18
-
19
- ### 1. Import and Configure
20
-
21
- ```typescript
22
- import { NativeUpdate } from 'native-update';
23
-
24
- // Initialize the plugin with your configuration
25
- async function initializeUpdates() {
26
- await NativeUpdate.configure({
27
- config: {
28
- // Live update settings
29
- autoUpdate: true,
30
- updateChannel: 'production',
31
- updateStrategy: 'IMMEDIATE',
32
-
33
- // Security settings
34
- enableSignatureVerification: true,
35
- publicKey: 'your-public-key',
36
-
37
- // App review settings
38
- minimumDaysSinceInstall: 7,
39
- minimumLaunchCount: 3,
40
- }
41
- });
42
- }
43
-
44
- // Call this when your app starts
45
- initializeUpdates();
46
- ```
47
-
48
- ## Live Updates (OTA)
49
-
50
- ### Check and Apply Updates Automatically
51
-
52
- ```typescript
53
- // Sync with server and apply updates if available
54
- async function syncUpdates() {
55
- try {
56
- const result = await NativeUpdate.sync();
57
-
58
- if (result.status === 'UPDATE_INSTALLED') {
59
- console.log('Update installed:', result.bundle.version);
60
- // Update will be applied based on your updateStrategy
61
- } else if (result.status === 'UP_TO_DATE') {
62
- console.log('App is up to date');
63
- }
64
- } catch (error) {
65
- console.error('Sync failed:', error);
66
- }
67
- }
68
- ```
69
-
70
- ### Manual Update Control
71
-
72
- ```typescript
73
- // Check for updates without downloading
74
- async function checkForUpdates() {
75
- const latest = await NativeUpdate.getLatest();
76
- const current = await NativeUpdate.current();
77
-
78
- if (latest.version !== current.version) {
79
- console.log(`Update available: ${latest.version}`);
80
- return true;
81
- }
82
- return false;
83
- }
84
-
85
- // Download and install update manually
86
- async function downloadAndInstallUpdate() {
87
- try {
88
- // Download the latest version
89
- const bundle = await NativeUpdate.download({
90
- version: 'latest',
91
- });
92
-
93
- // Set it as active
94
- await NativeUpdate.set(bundle);
95
-
96
- // Reload the app to apply
97
- await NativeUpdate.reload();
98
- } catch (error) {
99
- console.error('Update failed:', error);
100
- }
101
- }
102
- ```
103
-
104
- ### Listen for Download Progress
105
-
106
- ```typescript
107
- // Add download progress listener
108
- const progressListener = await NativeUpdate.addListener(
109
- 'downloadProgress',
110
- (progress) => {
111
- console.log(`Download: ${progress.percent}% complete`);
112
- console.log(`${progress.bytesDownloaded} / ${progress.totalBytes} bytes`);
113
- }
114
- );
115
-
116
- // Remember to remove listener when done
117
- // progressListener.remove();
118
- ```
119
-
120
- ## Native App Updates
121
-
122
- ### Check for App Store Updates
123
-
124
- ```typescript
125
- async function checkAppStoreUpdate() {
126
- try {
127
- const updateInfo = await NativeUpdate.getAppUpdateInfo();
128
-
129
- if (updateInfo.updateAvailable) {
130
- console.log(`New version available: ${updateInfo.availableVersion}`);
131
-
132
- if (updateInfo.updatePriority >= 4) {
133
- // High priority - immediate update
134
- await NativeUpdate.performImmediateUpdate();
135
- } else {
136
- // Optional update
137
- showUpdateDialog(updateInfo);
138
- }
139
- }
140
- } catch (error) {
141
- console.error('App update check failed:', error);
142
- }
143
- }
144
-
145
- function showUpdateDialog(updateInfo) {
146
- // Show your custom update UI
147
- if (userAcceptsUpdate) {
148
- NativeUpdate.openAppStore();
149
- }
150
- }
151
- ```
152
-
153
- ### Flexible Updates (Android)
154
-
155
- ```typescript
156
- // Start downloading in background
157
- async function startFlexibleUpdate() {
158
- await NativeUpdate.startFlexibleUpdate();
159
-
160
- // Listen for download completion
161
- const listener = await NativeUpdate.addListener(
162
- 'appUpdateStateChanged',
163
- (state) => {
164
- if (state.status === 'DOWNLOADED') {
165
- // Prompt user to restart
166
- showRestartPrompt();
167
- }
168
- }
169
- );
170
- }
171
-
172
- // Complete the update
173
- async function completeUpdate() {
174
- await NativeUpdate.completeFlexibleUpdate();
175
- // App will restart with new version
176
- }
177
- ```
178
-
179
- ## App Reviews
180
-
181
- ### Request Review at the Right Time
182
-
183
- ```typescript
184
- async function requestReviewIfAppropriate() {
185
- try {
186
- // Check if we can request a review
187
- const canRequest = await NativeUpdate.canRequestReview();
188
-
189
- if (canRequest.allowed) {
190
- // Request the review
191
- const result = await NativeUpdate.requestReview();
192
-
193
- if (result.shown) {
194
- console.log('Review dialog was shown');
195
- }
196
- } else {
197
- console.log('Cannot request review:', canRequest.reason);
198
- }
199
- } catch (error) {
200
- console.error('Review request failed:', error);
201
- }
202
- }
203
-
204
- // Call after positive user actions
205
- // e.g., after completing a task, making a purchase, etc.
206
- requestReviewIfAppropriate();
207
- ```
208
-
209
- ## Common Patterns
210
-
211
- ### Initialize on App Start
212
-
213
- ```typescript
214
- // In your main app component
215
- import { App } from '@capacitor/app';
216
- import { NativeUpdate } from 'native-update';
217
-
218
- App.addListener('appStateChange', async ({ isActive }) => {
219
- if (isActive) {
220
- // Check for updates when app becomes active
221
- await NativeUpdate.sync({
222
- installMode: 'ON_NEXT_RESUME',
223
- });
224
- }
225
- });
226
- ```
227
-
228
- ### Handle Update Lifecycle
229
-
230
- ```typescript
231
- class UpdateManager {
232
- async initialize() {
233
- // Configure plugin
234
- await NativeUpdate.configure({
235
- liveUpdate: {
236
- appId: 'your-app-id',
237
- serverUrl: 'https://your-server.com',
238
- autoUpdate: true,
239
- },
240
- });
241
-
242
- // Set up listeners
243
- this.setupListeners();
244
-
245
- // Initial sync
246
- await this.checkForUpdates();
247
- }
248
-
249
- setupListeners() {
250
- // Listen for update state changes
251
- NativeUpdate.addListener(
252
- 'updateStateChanged',
253
- (event) => {
254
- console.log('Update state:', event.status);
255
- this.handleUpdateState(event);
256
- }
257
- );
258
- }
259
-
260
- async checkForUpdates() {
261
- try {
262
- const result = await NativeUpdate.sync();
263
-
264
- if (result.status === 'UPDATE_INSTALLED') {
265
- // Notify user about update
266
- this.notifyUpdateInstalled(result.bundle.version);
267
- }
268
- } catch (error) {
269
- console.error('Update check failed:', error);
270
- }
271
- }
272
-
273
- handleUpdateState(event) {
274
- switch (event.status) {
275
- case 'DOWNLOADING':
276
- // Show progress indicator
277
- break;
278
- case 'READY':
279
- // Update downloaded, ready to install
280
- break;
281
- case 'FAILED':
282
- // Handle failure
283
- break;
284
- }
285
- }
286
- }
287
- ```
288
-
289
- ### Error Handling Best Practices
290
-
291
- ```typescript
292
- import { NativeUpdateError } from 'native-update';
293
-
294
- async function safeUpdateCheck() {
295
- try {
296
- await NativeUpdate.sync();
297
- } catch (error) {
298
- if (error instanceof NativeUpdateError) {
299
- switch (error.code) {
300
- case 'NETWORK_ERROR':
301
- // Handle network issues
302
- console.log('No internet connection');
303
- break;
304
- case 'SERVER_ERROR':
305
- // Server issues
306
- console.log('Update server unavailable');
307
- break;
308
- case 'VERIFICATION_ERROR':
309
- // Security validation failed
310
- console.log('Update verification failed');
311
- break;
312
- default:
313
- console.error('Update error:', error.message);
314
- }
315
- }
316
- }
317
- }
318
- ```
319
-
320
- ## Testing Your Implementation
321
-
322
- ### Development Tips
323
-
324
- 1. **Use staging channel for testing**:
325
-
326
- ```typescript
327
- await NativeUpdate.setChannel('staging');
328
- ```
329
-
330
- 2. **Enable debug mode for app reviews**:
331
-
332
- ```typescript
333
- await NativeUpdate.configure({
334
- appReview: {
335
- debugMode: true, // Bypass time restrictions
336
- },
337
- });
338
- ```
339
-
340
- 3. **Force update check**:
341
- ```typescript
342
- // Clear cache and check
343
- await NativeUpdate.sync({
344
- forceCheck: true,
345
- });
346
- ```
347
-
348
- ## Setting Up Backend & Creating Updates
349
-
350
- ### Quick Backend Setup
351
-
352
- Use our CLI to quickly set up a backend:
353
-
354
- ```bash
355
- # Create an Express.js backend with admin dashboard
356
- npx native-update backend create express --with-admin
357
-
358
- # Or create a Firebase Functions backend
359
- npx native-update backend create firebase --with-monitoring
360
-
361
- # Start the development server
362
- cd native-update-backend
363
- yarn install
364
- yarn dev
365
- ```
366
-
367
- ### Creating and Deploying Updates
368
-
369
- 1. **Generate signing keys** (see [Key Management Guide](https://nativeupdate.aoneahsan.com/docs/guides/key-management) for details):
370
- ```bash
371
- npx native-update keys generate --type rsa --size 4096
372
- ```
373
- This creates a private key (keep secret) and public key (add to app config)
374
-
375
- 2. **Build and create update bundle**:
376
- ```bash
377
- yarn build
378
- npx native-update bundle create ./www --version 1.0.1
379
- ```
380
-
381
- 3. **Sign the bundle**:
382
- ```bash
383
- npx native-update bundle sign ./update-bundles/bundle-*.zip --key ./keys/private-*.pem
384
- ```
385
-
386
- 4. **Upload via admin dashboard or API**
387
-
388
- ### Development Server
389
-
390
- For local testing:
391
- ```bash
392
- # Start a local update server
393
- npx native-update server start --port 3000
394
-
395
- # Monitor updates in real-time
396
- npx native-update monitor --server http://localhost:3000
397
- ```
398
-
399
- ## Next Steps
400
-
401
- Now that you have the basics working:
402
-
403
- 1. Deploy your backend to production
404
- 2. Implement [Security Best Practices](https://nativeupdate.aoneahsan.com/docs/guides/security-best-practices)
405
- 3. Configure [Advanced Options](https://nativeupdate.aoneahsan.com/docs/getting-started/configuration)
406
- 4. Explore [API Reference](https://nativeupdate.aoneahsan.com/docs/api/live-update-api) for all available methods
407
- 5. See [CLI Reference](https://nativeupdate.aoneahsan.com/docs/cli-reference) for all available commands
408
-
409
- ## Quick Reference
410
-
411
- ### Essential Methods
412
-
413
- | Method | Purpose |
414
- | ------------------------------ | ------------------------------- |
415
- | `configure()` | Initialize plugin with settings |
416
- | `sync()` | Check and apply updates |
417
- | `current()` | Get current bundle info |
418
- | `getAppUpdateInfo()` | Check app store updates |
419
- | `requestReview()` | Request user review |
420
-
421
- ### Key Events
422
-
423
- | Event | Description |
424
- | -------------------- | ------------------------ |
425
- | `downloadProgress` | Update download progress |
426
- | `updateStateChanged` | Bundle state changes |
427
-
428
- ---
429
-
430
- Made with ❤️ by Ahsan Mahmood
@@ -1,183 +0,0 @@
1
- # Backend Templates Guide
2
-
3
- This guide explains the backend templates provided by the native-update CLI and how to customize them for your production environment.
4
-
5
- ## Overview
6
-
7
- The `npx native-update backend create <type>` command generates backend templates for managing OTA updates. These templates are **starting points** that require customization for your specific infrastructure.
8
-
9
- ## Available Templates
10
-
11
- | Template | Command | Use Case |
12
- |----------|---------|----------|
13
- | Express.js | `npx native-update backend create express` | Self-hosted Node.js server |
14
- | Firebase | `npx native-update backend create firebase` | Serverless with Firebase Functions |
15
- | Vercel | `npx native-update backend create vercel` | Serverless with Vercel Edge Functions |
16
-
17
- ## Template Structure
18
-
19
- Each template includes:
20
-
21
- ```
22
- native-update-backend/
23
- ├── src/
24
- │ ├── routes/
25
- │ │ ├── updates.js # Update check/download endpoints
26
- │ │ └── admin.js # Admin dashboard routes (if --with-admin)
27
- │ ├── services/
28
- │ │ ├── storage.js # Bundle storage service (CUSTOMIZE THIS)
29
- │ │ └── database.js # Metadata storage (CUSTOMIZE THIS)
30
- │ └── index.js # Entry point
31
- ├── package.json
32
- └── README.md
33
- ```
34
-
35
- ## Understanding Placeholder Code
36
-
37
- The generated templates contain placeholder implementations marked with comments explaining what you need to implement. These are **intentional customization points**, not incomplete code.
38
-
39
- ### Example: Storage Service
40
-
41
- ```javascript
42
- // storage.js - CUSTOMIZE FOR YOUR INFRASTRUCTURE
43
- export async function storeBundle(bundleId, file) {
44
- // Implement your storage logic here
45
- // Options:
46
- // - AWS S3: Use @aws-sdk/client-s3
47
- // - Google Cloud Storage: Use @google-cloud/storage
48
- // - Azure Blob: Use @azure/storage-blob
49
- // - Local filesystem: Use fs/promises
50
- throw new Error('Storage not configured - implement storeBundle()');
51
- }
52
-
53
- export async function getBundle(bundleId) {
54
- // Implement your retrieval logic here
55
- throw new Error('Storage not configured - implement getBundle()');
56
- }
57
- ```
58
-
59
- ### Example: Database Service
60
-
61
- ```javascript
62
- // database.js - CUSTOMIZE FOR YOUR INFRASTRUCTURE
63
- export async function saveBundleMetadata(metadata) {
64
- // Implement your database logic here
65
- // Options:
66
- // - PostgreSQL: Use pg or prisma
67
- // - MongoDB: Use mongoose
68
- // - Firebase Firestore: Use firebase-admin
69
- // - MySQL: Use mysql2
70
- throw new Error('Database not configured - implement saveBundleMetadata()');
71
- }
72
- ```
73
-
74
- ## Customization Guide
75
-
76
- ### Step 1: Choose Your Storage
77
-
78
- | Storage Option | Package | Best For |
79
- |----------------|---------|----------|
80
- | AWS S3 | `@aws-sdk/client-s3` | Production, scalable |
81
- | Google Cloud Storage | `@google-cloud/storage` | GCP infrastructure |
82
- | Azure Blob | `@azure/storage-blob` | Azure infrastructure |
83
- | Local Filesystem | `fs/promises` | Development only |
84
- | Cloudflare R2 | `@aws-sdk/client-s3` | Cost-effective |
85
-
86
- ### Step 2: Choose Your Database
87
-
88
- | Database Option | Package | Best For |
89
- |----------------|---------|----------|
90
- | PostgreSQL | `pg`, `prisma` | Production, relational |
91
- | MongoDB | `mongoose` | Document-based |
92
- | Firebase Firestore | `firebase-admin` | Serverless |
93
- | SQLite | `better-sqlite3` | Small deployments |
94
- | Redis | `ioredis` | Caching, fast reads |
95
-
96
- ### Step 3: Implement the Services
97
-
98
- Replace the placeholder functions with your actual implementations:
99
-
100
- ```javascript
101
- // Example: AWS S3 implementation
102
- import { S3Client, PutObjectCommand, GetObjectCommand } from '@aws-sdk/client-s3';
103
-
104
- const s3 = new S3Client({ region: process.env.AWS_REGION });
105
-
106
- export async function storeBundle(bundleId, file) {
107
- await s3.send(new PutObjectCommand({
108
- Bucket: process.env.S3_BUCKET,
109
- Key: `bundles/${bundleId}.zip`,
110
- Body: file,
111
- }));
112
- return `bundles/${bundleId}.zip`;
113
- }
114
-
115
- export async function getBundle(bundleId) {
116
- const response = await s3.send(new GetObjectCommand({
117
- Bucket: process.env.S3_BUCKET,
118
- Key: `bundles/${bundleId}.zip`,
119
- }));
120
- return response.Body;
121
- }
122
- ```
123
-
124
- ## Template Options
125
-
126
- ### --with-admin
127
-
128
- Adds an admin dashboard for:
129
- - Viewing deployed bundles
130
- - Monitoring update adoption
131
- - Managing channels
132
- - Viewing device statistics
133
-
134
- ### --with-monitoring
135
-
136
- Adds monitoring endpoints for:
137
- - Health checks
138
- - Prometheus metrics
139
- - Update success/failure rates
140
- - Download statistics
141
-
142
- ## Production Checklist
143
-
144
- Before deploying to production:
145
-
146
- - [ ] Implement storage service for your cloud provider
147
- - [ ] Implement database service for metadata
148
- - [ ] Configure environment variables
149
- - [ ] Set up authentication for admin endpoints
150
- - [ ] Configure HTTPS/TLS
151
- - [ ] Set up rate limiting
152
- - [ ] Configure logging (Winston, Pino, etc.)
153
- - [ ] Set up error tracking (Sentry, etc.)
154
- - [ ] Configure backup strategy for bundles
155
-
156
- ## Environment Variables
157
-
158
- Templates expect these environment variables:
159
-
160
- ```env
161
- # Server
162
- PORT=3000
163
- NODE_ENV=production
164
-
165
- # Storage (example for S3)
166
- AWS_REGION=us-east-1
167
- S3_BUCKET=my-update-bundles
168
- AWS_ACCESS_KEY_ID=xxx
169
- AWS_SECRET_ACCESS_KEY=xxx
170
-
171
- # Database (example for PostgreSQL)
172
- DATABASE_URL=postgres://user:pass@host:5432/dbname
173
-
174
- # Security
175
- API_KEY=your-admin-api-key
176
- SIGNING_PUBLIC_KEY_PATH=./keys/public.pem
177
- ```
178
-
179
- ## Related Documentation
180
-
181
- - [Deployment Guide](https://nativeupdate.aoneahsan.com/docs/guides/deployment-guide) - Full deployment instructions
182
- - [Security Best Practices](https://nativeupdate.aoneahsan.com/docs/guides/security-best-practices) - Security recommendations
183
- - [Key Management](https://nativeupdate.aoneahsan.com/docs/guides/key-management) - Managing signing keys