native-update 3.1.2 → 3.1.4

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 (206) 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/cli/AGENTS.md +1 -1
  6. package/cli/CLAUDE.md +1 -1
  7. package/cli/commands/bundle-create.js +2 -2
  8. package/cli/index.js +11 -0
  9. package/dist/esm/definitions.d.ts +8 -0
  10. package/dist/esm/plugin.js +16 -2
  11. package/dist/plugin.cjs.js +1 -1
  12. package/dist/plugin.esm.js +1 -1
  13. package/dist/plugin.js +2 -2
  14. package/docs/CHANGELOG.md +90 -0
  15. package/docs/KNOWN_LIMITATIONS.md +2 -2
  16. package/docs/MIGRATION.md +1 -1
  17. package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +64 -8
  18. package/ios/Plugin/NativeUpdatePlugin.swift +39 -13
  19. package/package.json +8 -3
  20. package/docs/AGENTS.md +0 -47
  21. package/docs/APP_REVIEW_GUIDE.md +0 -768
  22. package/docs/BUNDLE_SIGNING.md +0 -277
  23. package/docs/CLAUDE.md +0 -110
  24. package/docs/COMPREHENSIVE_AUDIT_REPORT.md +0 -526
  25. package/docs/DEPLOY_NOTES.md +0 -116
  26. package/docs/EXAMPLE_APPS_SIMPLIFICATION_PLAN.md +0 -384
  27. package/docs/EXAMPLE_APPS_SIMPLIFICATION_TRACKER.md +0 -390
  28. package/docs/LIVE_UPDATES_GUIDE.md +0 -675
  29. package/docs/MANUAL-TASKS.md +0 -30
  30. package/docs/MARKETING_WEBSITE_TRACKER.md +0 -677
  31. package/docs/NATIVE_UPDATES_GUIDE.md +0 -695
  32. package/docs/PACKAGES.md +0 -167
  33. package/docs/PERFORMANCE.md +0 -110
  34. package/docs/PROJECT_COMPLETION_TRACKER.md +0 -411
  35. package/docs/QUICK_START.md +0 -595
  36. package/docs/README.md +0 -130
  37. package/docs/REMAINING_FEATURES.md +0 -192
  38. package/docs/ROADMAP.md +0 -295
  39. package/docs/SECURITY-IF-REPO-PUBLIC.md +0 -232
  40. package/docs/SECURITY.md +0 -356
  41. package/docs/TESTING_REQUIREMENTS.md +0 -201
  42. package/docs/ai-knowledge-base/00-project-profile.md +0 -38
  43. package/docs/ai-knowledge-base/01-features.md +0 -46
  44. package/docs/ai-knowledge-base/02-routes.md +0 -72
  45. package/docs/ai-knowledge-base/03-tech-stack.md +0 -57
  46. package/docs/ai-knowledge-base/README.md +0 -23
  47. package/docs/analytics-tracking.md +0 -37
  48. package/docs/api/API.md +0 -558
  49. package/docs/api/FEATURES.md +0 -414
  50. package/docs/api/app-review-api.md +0 -239
  51. package/docs/api/app-update-api.md +0 -154
  52. package/docs/api/background-update-api.md +0 -170
  53. package/docs/api/events-api.md +0 -323
  54. package/docs/api/live-update-api.md +0 -258
  55. package/docs/archive/MARKETING_WEBSITE_PLAN.md +0 -659
  56. package/docs/background-updates.md +0 -392
  57. package/docs/capacitor-official-plugins.md +0 -46
  58. package/docs/capawesome-plugins.md +0 -29
  59. package/docs/cli-reference.md +0 -321
  60. package/docs/deployment/HOSTINGER_DEPLOY.md +0 -370
  61. package/docs/deployment/PRODUCTION-DEPLOY-CHECKLIST.md +0 -184
  62. package/docs/docs-site/plan.md +0 -201
  63. package/docs/docs-site/scope.md +0 -127
  64. package/docs/docs-site/tracker.json +0 -235
  65. package/docs/error-handling-tracking.md +0 -37
  66. package/docs/examples/advanced-scenarios.md +0 -394
  67. package/docs/examples/android-manifest-example.xml +0 -77
  68. package/docs/examples/basic-usage.md +0 -206
  69. package/docs/examples/node-express-backend-example.md +0 -28
  70. package/docs/examples/react-capacitor-example.md +0 -29
  71. package/docs/features/app-reviews.md +0 -975
  72. package/docs/features/app-updates.md +0 -785
  73. package/docs/features/e2e-full-verification/00-overview.md +0 -99
  74. package/docs/features/e2e-full-verification/00-tracker.json +0 -284
  75. package/docs/features/e2e-full-verification/phase01-backend-schema-fixes.md +0 -183
  76. package/docs/features/e2e-full-verification/phase02-test-auth.md +0 -176
  77. package/docs/features/e2e-full-verification/phase03-api-test-coverage.md +0 -63
  78. package/docs/features/e2e-full-verification/phase04-frontend-package-contract-audit.md +0 -73
  79. package/docs/features/e2e-full-verification/phase05-browser-e2e-matrix.md +0 -69
  80. package/docs/features/e2e-full-verification/phase06-deploy-prod-smoke.md +0 -51
  81. package/docs/features/e2e-full-verification/results/phase01-drift-report.md +0 -50
  82. package/docs/features/e2e-full-verification/results/phase03-coverage-matrix.md +0 -215
  83. package/docs/features/e2e-full-verification/results/phase04-frontend-contract.md +0 -139
  84. package/docs/features/e2e-full-verification/results/phase05-e2e-results.md +0 -99
  85. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-01-dashboard.png +0 -0
  86. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-02-signup.png +0 -0
  87. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-03-settings-persisted.png +0 -0
  88. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-04a-app-created.png +0 -0
  89. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-04b-duplicate-bundle-422.png +0 -0
  90. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-05-plan-limit-403.png +0 -0
  91. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-08a-upload-graceful-fail.png +0 -0
  92. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-08b-builds-list.png +0 -0
  93. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-10-rollout-25pct.png +0 -0
  94. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-11-analytics.png +0 -0
  95. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-12-drive-disconnected.png +0 -0
  96. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-13-pricing.png +0 -0
  97. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-14-isolation-403.png +0 -0
  98. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-15a-admin-overview.png +0 -0
  99. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-15b-regular-user-admin-redirect.png +0 -0
  100. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-16a-delete-dialog.png +0 -0
  101. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-17-mobile-375.png +0 -0
  102. package/docs/features/e2e-full-verification/results/route-list.json +0 -1
  103. package/docs/features/laravel-nova-backend/ASSESSMENT-SUMMARY.md +0 -96
  104. package/docs/features/laravel-nova-backend/IMPLEMENTATION-PLAN.md +0 -504
  105. package/docs/features/laravel-nova-backend/progress-tracker.json +0 -184
  106. package/docs/features/live-updates.md +0 -642
  107. package/docs/features/queues-and-emails/00-overview.md +0 -41
  108. package/docs/features/queues-and-emails/00-tracker.json +0 -99
  109. package/docs/features/queues-and-emails/phase01-foundation.md +0 -15
  110. package/docs/features/queues-and-emails/phase02-queued-jobs.md +0 -19
  111. package/docs/features/queues-and-emails/phase03-transactional-emails.md +0 -16
  112. package/docs/features/queues-and-emails/phase04-quota-ops.md +0 -17
  113. package/docs/features/queues-and-emails/phase05-async-build-processing-DECISION.md +0 -16
  114. package/docs/features/queues-and-emails/phase06-verify-deploy.md +0 -17
  115. package/docs/getting-started/configuration.md +0 -469
  116. package/docs/getting-started/installation.md +0 -300
  117. package/docs/getting-started/quick-start.md +0 -430
  118. package/docs/guides/BACKEND_TEMPLATES_GUIDE.md +0 -183
  119. package/docs/guides/admin-panel.md +0 -268
  120. package/docs/guides/channel-management.md +0 -343
  121. package/docs/guides/dashboard-guide.md +0 -365
  122. package/docs/guides/deployment-guide.md +0 -335
  123. package/docs/guides/end-to-end-workflow.md +0 -491
  124. package/docs/guides/key-management.md +0 -284
  125. package/docs/guides/migration-from-codepush.md +0 -145
  126. package/docs/guides/security-best-practices.md +0 -1057
  127. package/docs/guides/testing-guide.md +0 -346
  128. package/docs/guides/troubleshooting.md +0 -482
  129. package/docs/package-audit.md +0 -41
  130. package/docs/plans/PLANNING_COMPLETE_SUMMARY.md +0 -361
  131. package/docs/plans/TASK_1_ANDROID_EXAMPLE_APP.md +0 -401
  132. package/docs/plans/TASK_2_API_ENDPOINTS.md +0 -856
  133. package/docs/plans/TASK_2_DASHBOARD_UI_UX.md +0 -820
  134. package/docs/plans/TASK_2_DATABASE_SCHEMA.md +0 -704
  135. package/docs/plans/TASK_2_GOOGLE_DRIVE_INTEGRATION.md +0 -646
  136. package/docs/plans/TASK_2_SAAS_ARCHITECTURE.md +0 -587
  137. package/docs/plans/TASK_2_USER_AUTHENTICATION.md +0 -600
  138. package/docs/play-store/ASO-METADATA.md +0 -5
  139. package/docs/play-store/DATA-SAFETY.md +0 -5
  140. package/docs/play-store/DECLARATIONS.md +0 -5
  141. package/docs/play-store/README.md +0 -27
  142. package/docs/play-store/RELEASE-NOTES.md +0 -99
  143. package/docs/play-store/RELEASE-STEPS.md +0 -6
  144. package/docs/play-store/STORE-LISTING.md +0 -7
  145. package/docs/play-store/SUBMISSION-CHECKLIST.md +0 -5
  146. package/docs/production-readiness.md +0 -475
  147. package/docs/project-audit/2026-05-16/00-FINALIZATION-PLAN.md +0 -123
  148. package/docs/project-audit/2026-05-16/01-BATCH-PLAN.md +0 -227
  149. package/docs/project-audit/2026-05-16/02-AUDIT-FINDINGS.md +0 -144
  150. package/docs/project-audit/2026-05-16/sessions/batch-01.md +0 -42
  151. package/docs/project-audit/2026-05-16/sessions/batch-02.md +0 -74
  152. package/docs/project-audit/2026-05-16/sessions/batch-03.md +0 -71
  153. package/docs/project-audit/2026-05-16/sessions/batch-04.md +0 -88
  154. package/docs/project-audit/2026-05-16/sessions/batch-05.md +0 -63
  155. package/docs/project-audit/2026-05-16/sessions/batch-06.md +0 -103
  156. package/docs/project-audit/2026-05-16/sessions/batch-07.md +0 -61
  157. package/docs/project-audit/2026-05-16/sessions/batch-08.md +0 -101
  158. package/docs/project-audit/2026-05-16/sessions/batch-09.md +0 -105
  159. package/docs/project-audit/2026-05-16/sessions/batch-10.md +0 -102
  160. package/docs/project-audit/AUDIT-HISTORY.md +0 -74
  161. package/docs/project-audit/BATCH-PLAN.md +0 -168
  162. package/docs/project-audit/MARKETING-WEBSITE-FINDINGS-2026-05-11.md +0 -73
  163. package/docs/project-audit/PRODUCTION-READINESS-AUDIT-2026-05-08.md +0 -275
  164. package/docs/project-finalization/00-tracker.json +0 -60
  165. package/docs/project-knowledge-base/01-system-overview.md +0 -227
  166. package/docs/project-knowledge-base/02-routes-pages-forms-users.md +0 -352
  167. package/docs/project-knowledge-base/03-tech-stack-modules-services.md +0 -379
  168. package/docs/project-knowledge-base/04-data-models-integrations.md +0 -244
  169. package/docs/project-knowledge-base/05-docs-corpus-inventory.md +0 -256
  170. package/docs/project-knowledge-base/06-operations-testing-legal-content.md +0 -208
  171. package/docs/project-knowledge-base/README.md +0 -103
  172. package/docs/project-profiles/native-update-capacitor-update-platform-project-profile-last-updated-2026-05-19.md +0 -81
  173. package/docs/reports/AUDIT_SUMMARY_2025-12-26.md +0 -203
  174. package/docs/reports/CLAUDE-CODE-COMPLETION-PROMPT.md +0 -403
  175. package/docs/reports/CLAUDE_CODE_PROMPT.md +0 -29
  176. package/docs/reports/CODEBASE_STATUS_REPORT.md +0 -272
  177. package/docs/reports/COMPLETE_VERIFICATION.md +0 -106
  178. package/docs/reports/COMPREHENSIVE-PROJECT-AUDIT-2026-02-24.md +0 -747
  179. package/docs/reports/EVENT_FLOW_VERIFICATION.md +0 -80
  180. package/docs/reports/EXAMPLE_APPS_SIMPLIFICATION_COMPLETE.md +0 -369
  181. package/docs/reports/FINAL_STATUS.md +0 -122
  182. package/docs/reports/FINAL_VERIFICATION_CHECKLIST.md +0 -425
  183. package/docs/reports/MARKETING_WEBSITE_COMPLETE.md +0 -466
  184. package/docs/reports/PACKAGE_COMPLETENESS_REPORT.md +0 -130
  185. package/docs/reports/PRODUCTION_STATUS.md +0 -115
  186. package/docs/reports/PROJECT_RESTRUCTURE_2025-12-27.md +0 -287
  187. package/docs/reports/PROJECT_RESTRUCTURE_FINAL_SUMMARY.md +0 -464
  188. package/docs/reports/PUBLISHING_VERIFICATION.md +0 -144
  189. package/docs/reports/RELEASE_READY_SUMMARY.md +0 -99
  190. package/docs/reports/claude-completion.json +0 -241
  191. package/docs/rules-tracker.md +0 -102
  192. package/docs/security/PRE-LAUNCH-PENTEST-CHECKLIST.md +0 -116
  193. package/docs/security/certificate-pinning.md +0 -122
  194. package/docs/seo-aeo-rules.json +0 -3043
  195. package/docs/social-media-marketing/README.md +0 -81
  196. package/docs/social-media-marketing/posts-batch-01.md +0 -613
  197. package/docs/social-media-marketing/posts-batch-02.md +0 -528
  198. package/docs/social-media-marketing/whatsapp-messages-batch-01.md +0 -458
  199. package/docs/social-media-marketing/whatsapp-status-batch-01.md +0 -355
  200. package/docs/tracking/IMPLEMENTATION_TRACKER.md +0 -303
  201. package/docs/tracking/capacitor-rollout-note-2026-03-01.md +0 -21
  202. package/docs/tracking/completion-tracker-2026-02-24.json +0 -174
  203. package/docs/tracking/finalization-2026-05-16-tracker.json +0 -346
  204. package/docs/tracking/full-audit-tracker.json +0 -121
  205. package/docs/tracking/production-readiness-audit-tracker.json +0 -429
  206. package/docs/tracking/seo-checklist-tracker.json +0 -333
@@ -1,154 +0,0 @@
1
- # App Update API Reference
2
-
3
- Complete API documentation for native app store update functionality.
4
-
5
- ## Methods
6
-
7
- ### getAppUpdateInfo()
8
-
9
- Get information about available app updates in the app store.
10
-
11
- ```typescript
12
- const result = await NativeUpdate.getAppUpdateInfo();
13
- // Returns:
14
- {
15
- updateAvailable: boolean;
16
- currentVersion: string;
17
- availableVersion?: string;
18
- updatePriority?: 'LOW' | 'MEDIUM' | 'HIGH' | 'IMMEDIATE';
19
- releaseNotes?: string;
20
- updateSize?: number;
21
-
22
- // Android specific
23
- immediateUpdateAllowed?: boolean;
24
- flexibleUpdateAllowed?: boolean;
25
- clientVersionStalenessDays?: number;
26
-
27
- // iOS specific
28
- updateURL?: string;
29
- }
30
- ```
31
-
32
- ### performImmediateUpdate()
33
-
34
- Perform an immediate (blocking) update. Android only - shows full-screen update UI.
35
-
36
- ```typescript
37
- try {
38
- await NativeUpdate.performImmediateUpdate();
39
- // App will restart after update
40
- } catch (error) {
41
- // User cancelled or update failed
42
- }
43
- ```
44
-
45
- ### startFlexibleUpdate()
46
-
47
- Start a flexible (background) update. Android only - downloads in background.
48
-
49
- ```typescript
50
- await NativeUpdate.startFlexibleUpdate();
51
- // Monitor progress with appUpdateProgress event
52
- ```
53
-
54
- ### completeFlexibleUpdate()
55
-
56
- Complete a flexible update installation. Android only.
57
-
58
- ```typescript
59
- await NativeUpdate.completeFlexibleUpdate();
60
- // App will restart
61
- ```
62
-
63
- ### openAppStore()
64
-
65
- Open the app store page for updates.
66
-
67
- ```typescript
68
- await NativeUpdate.openAppStore({
69
- // Optional: specify app ID for iOS or package name for Android
70
- appId: 'your-app-id'
71
- });
72
- ```
73
-
74
- ## Events
75
-
76
- App update events are available for monitoring the native app update process. See the [Events API Reference](https://nativeupdate.aoneahsan.com/docs/api/events-api#app-update-events) for complete documentation of the following events:
77
-
78
- - `appUpdateStateChanged` - Fired when update state changes
79
- - `appUpdateProgress` - Monitor download progress for flexible updates
80
- - `appUpdateAvailable` - Notified when a new version is available
81
- - `appUpdateReady` - Update downloaded and ready to install
82
- - `appUpdateFailed` - Update process failed
83
- - `appUpdateNotificationClicked` - User clicked update notification
84
- - `appUpdateInstallClicked` - User clicked install in notification
85
-
86
- ## Platform Differences
87
-
88
- ### Android (Google Play)
89
-
90
- - Supports in-app updates via Play Core Library
91
- - Two update modes: Immediate and Flexible
92
- - Can force critical updates
93
- - Shows native update UI
94
- - Handles download and installation
95
-
96
- ### iOS (App Store)
97
-
98
- - No in-app update API available
99
- - Can only check version and open App Store
100
- - Version checking requires backend service
101
- - Updates handled entirely by App Store app
102
-
103
- ### Web
104
-
105
- - Shows update notification only
106
- - Can redirect to web app URL
107
- - Version checking via backend
108
-
109
- ## Error Codes
110
-
111
- | Code | Description |
112
- |------|-------------|
113
- | `UPDATE_NOT_AVAILABLE` | No update available |
114
- | `UPDATE_IN_PROGRESS` | Update already downloading |
115
- | `UPDATE_FAILED` | Update download/install failed |
116
- | `USER_CANCELLED` | User cancelled the update |
117
- | `PLATFORM_NOT_SUPPORTED` | Feature not supported on platform |
118
- | `STORE_NOT_FOUND` | App store app not installed |
119
- | `NETWORK_ERROR` | Network connection failed |
120
-
121
- ## Best Practices
122
-
123
- 1. **Check for updates on app start**
124
- ```typescript
125
- async function checkOnStart() {
126
- const result = await NativeUpdate.getAppUpdateInfo();
127
- if (result.updateAvailable && result.updatePriority === 'IMMEDIATE') {
128
- await NativeUpdate.performImmediateUpdate();
129
- }
130
- }
131
- ```
132
-
133
- 2. **Handle flexible updates**
134
- ```typescript
135
- // Start download
136
- await NativeUpdate.startFlexibleUpdate();
137
-
138
- // Note: Progress monitoring for native app updates is handled
139
- // internally by the platform. For Android, the Play Core library
140
- // shows its own UI. For custom progress tracking, use Live Updates
141
- // instead of native app updates.
142
- ```
143
-
144
- 3. **Fallback for iOS**
145
- ```typescript
146
- if (platform === 'ios') {
147
- const result = await NativeUpdate.getAppUpdateInfo();
148
- if (result.updateAvailable) {
149
- showUpdateDialog(() => {
150
- NativeUpdate.openAppStore();
151
- });
152
- }
153
- }
154
- ```
@@ -1,170 +0,0 @@
1
- # Background Update API Reference
2
-
3
- Complete API documentation for background update functionality.
4
-
5
- ## Methods
6
-
7
- ### enableBackgroundUpdates(config)
8
-
9
- Enable background update checking.
10
-
11
- ```typescript
12
- await NativeUpdate.enableBackgroundUpdates({
13
- checkInterval: 3600000, // Check every hour (in ms)
14
- requireWifi: true, // Only check on WiFi
15
- requireCharging: false, // Don't require charging
16
- updateTypes: ['live', 'native'], // Check both update types
17
- notificationConfig: {
18
- enabled: true,
19
- title: 'Update Available',
20
- autoCancel: true
21
- }
22
- });
23
- ```
24
-
25
- ### disableBackgroundUpdates()
26
-
27
- Disable all background update checks.
28
-
29
- ```typescript
30
- await NativeUpdate.disableBackgroundUpdates();
31
- ```
32
-
33
- ### getBackgroundUpdateStatus()
34
-
35
- Get current background update configuration and status.
36
-
37
- ```typescript
38
- const status = await NativeUpdate.getBackgroundUpdateStatus();
39
- // Returns:
40
- {
41
- enabled: boolean;
42
- lastCheckTime?: number;
43
- nextScheduledCheck?: number;
44
- checkInterval?: number;
45
- updateTypes: string[];
46
- notificationEnabled: boolean;
47
- }
48
- ```
49
-
50
- ### scheduleBackgroundCheck(options)
51
-
52
- Schedule a one-time background check.
53
-
54
- ```typescript
55
- await NativeUpdate.scheduleBackgroundCheck({
56
- delay: 60000, // Check in 1 minute
57
- type: 'live' // Check for live updates only
58
- });
59
- ```
60
-
61
- ### triggerBackgroundCheck()
62
-
63
- Immediately trigger a background update check.
64
-
65
- ```typescript
66
- const result = await NativeUpdate.triggerBackgroundCheck();
67
- // Returns:
68
- {
69
- liveUpdateAvailable: boolean;
70
- nativeUpdateAvailable: boolean;
71
- error?: string;
72
- }
73
- ```
74
-
75
- ### setNotificationPreferences(preferences)
76
-
77
- Configure notification preferences for background updates.
78
-
79
- ```typescript
80
- await NativeUpdate.setNotificationPreferences({
81
- enabled: true,
82
- showProgress: true,
83
- soundEnabled: false,
84
- vibrationEnabled: true,
85
- ledColor: '#00FF00',
86
- importance: 'HIGH'
87
- });
88
- ```
89
-
90
- ### getNotificationPermissions()
91
-
92
- Check current notification permissions.
93
-
94
- ```typescript
95
- const permissions = await NativeUpdate.getNotificationPermissions();
96
- // Returns:
97
- {
98
- granted: boolean;
99
- canRequestPermission: boolean;
100
- permanentlyDenied: boolean;
101
- }
102
- ```
103
-
104
- ### requestNotificationPermissions()
105
-
106
- Request notification permissions from the user.
107
-
108
- ```typescript
109
- const result = await NativeUpdate.requestNotificationPermissions();
110
- // Returns:
111
- {
112
- granted: boolean;
113
- permanentlyDenied: boolean;
114
- }
115
- ```
116
-
117
- ## Events
118
-
119
- ### backgroundUpdateProgress
120
-
121
- Fired during background update operations.
122
-
123
- ```typescript
124
- NativeUpdate.addListener('backgroundUpdateProgress', (event) => {
125
- console.log('Background update:', event.status);
126
- // event.type: 'live' | 'native'
127
- // event.status: 'checking' | 'downloading' | 'completed' | 'failed'
128
- });
129
- ```
130
-
131
- ### backgroundUpdateNotification
132
-
133
- Fired when background check finds an update.
134
-
135
- ```typescript
136
- NativeUpdate.addListener('backgroundUpdateNotification', (event) => {
137
- console.log('Update available:', event.updateAvailable);
138
- // event.type: 'live' | 'native'
139
- // event.version: string
140
- });
141
- ```
142
-
143
- ## Platform Notes
144
-
145
- ### Android
146
- - Uses WorkManager for reliable scheduling
147
- - Respects battery optimization settings
148
- - Requires notification permission for user alerts
149
-
150
- ### iOS
151
- - Uses BackgroundTasks framework
152
- - Limited by iOS background execution policies
153
- - May not run exactly at scheduled times
154
-
155
- ### Web
156
- - Uses Service Workers when available
157
- - Falls back to periodic checks when app is active
158
-
159
- ## Server contracts (what a background check calls)
160
-
161
- A background check can look for two different kinds of update, each with its
162
- own backend contract:
163
-
164
- | `updateType` | Endpoint | Auth | Purpose |
165
- |---|---|---|---|
166
- | `LIVE_UPDATE` | `GET {serverUrl}/v1/updates/check?channel=…` | `X-API-Key` + `X-Device-ID` headers | OTA bundle check — the **same** endpoint `NativeUpdate.checkForUpdate()` uses (implemented once in `src/core/update-check.ts`). Full contract: `docs/server-requirements.md`. |
167
- | `APP_UPDATE` | `GET {serverUrl}/app-version` | `X-Current-Version` + `X-Platform` headers | **Optional custom extension point** for server-driven *native app-store* update prompts. Not part of the Native Update (Laravel) OTA backend; a no-op unless you implement it. Returns `{ "version": "2.1.0", "priority": 3 }`. |
168
-
169
- The primary native app-update path is the platform store API (Play Core /
170
- App Store); the `/app-version` endpoint is only the optional server fallback.
@@ -1,323 +0,0 @@
1
- # Events API Reference
2
-
3
- Complete documentation for all events emitted by the Capacitor Native Update plugin.
4
-
5
- ## Event Listeners
6
-
7
- ### Adding Listeners
8
-
9
- ```typescript
10
- // Add a listener
11
- const listener = NativeUpdate.addListener('eventName', (data) => {
12
- console.log('Event data:', data);
13
- });
14
-
15
- // Remove a listener
16
- listener.remove();
17
-
18
- // Remove all listeners for an event
19
- NativeUpdate.removeAllListeners('eventName');
20
- ```
21
-
22
- ## Live Update Events
23
-
24
- ### updateStateChanged
25
-
26
- Fired when the update state changes during sync or download.
27
-
28
- ```typescript
29
- NativeUpdate.addListener('updateStateChanged', (state) => {
30
- console.log('Update state:', state);
31
- });
32
- ```
33
-
34
- **Event Data:**
35
- ```typescript
36
- {
37
- status: 'CHECKING' | 'DOWNLOADING' | 'READY' | 'FAILED' | 'INSTALLING';
38
- bundleId?: string;
39
- version?: string;
40
- previousState?: string;
41
- timestamp: number;
42
- }
43
- ```
44
-
45
- ### downloadProgress
46
-
47
- Fired periodically during bundle download.
48
-
49
- ```typescript
50
- NativeUpdate.addListener('downloadProgress', (progress) => {
51
- console.log(`Download: ${progress.percent}%`);
52
- });
53
- ```
54
-
55
- **Event Data:**
56
- ```typescript
57
- {
58
- percent: number; // 0-100
59
- bytesDownloaded: number; // Bytes downloaded so far
60
- totalBytes: number; // Total bundle size
61
- bytesPerSecond: number; // Download speed
62
- estimatedTime: number; // Seconds remaining
63
- bundleId: string; // Bundle being downloaded
64
- }
65
- ```
66
-
67
- ## App Update Events
68
-
69
- ### appUpdateStateChanged
70
-
71
- Fired when the native app update state changes.
72
-
73
- ```typescript
74
- NativeUpdate.addListener('appUpdateStateChanged', (state) => {
75
- console.log('App update state:', state.status);
76
- });
77
- ```
78
-
79
- **Event Data:**
80
- ```typescript
81
- {
82
- status: InstallStatus; // See InstallStatus enum
83
- installErrorCode?: number; // Error code if status is FAILED
84
- }
85
- ```
86
-
87
- ### appUpdateProgress
88
-
89
- Fired during app update download progress.
90
-
91
- ```typescript
92
- NativeUpdate.addListener('appUpdateProgress', (progress) => {
93
- console.log(`Download progress: ${progress.percent}%`);
94
- });
95
- ```
96
-
97
- **Event Data:**
98
- ```typescript
99
- {
100
- percent: number; // Download percentage (0-100)
101
- bytesDownloaded: number; // Bytes downloaded so far
102
- totalBytes: number; // Total download size
103
- }
104
- ```
105
-
106
- ### appUpdateAvailable
107
-
108
- Fired when a new app update is detected.
109
-
110
- ```typescript
111
- NativeUpdate.addListener('appUpdateAvailable', (info) => {
112
- console.log(`Update available: ${info.availableVersion}`);
113
- });
114
- ```
115
-
116
- **Event Data:**
117
- ```typescript
118
- {
119
- currentVersion: string;
120
- availableVersion: string;
121
- updatePriority: number; // 0-5, where 5 is critical
122
- updateSize?: number; // Update size in bytes
123
- releaseNotes?: string[]; // Release notes array
124
- storeUrl?: string; // App store URL
125
- }
126
- ```
127
-
128
- ### appUpdateReady
129
-
130
- Fired when the app update is downloaded and ready to install.
131
-
132
- ```typescript
133
- NativeUpdate.addListener('appUpdateReady', (event) => {
134
- console.log('Update ready to install');
135
- // Prompt user to restart/install
136
- });
137
- ```
138
-
139
- **Event Data:**
140
- ```typescript
141
- {
142
- message: string; // "Update downloaded and ready to install"
143
- }
144
- ```
145
-
146
- ### appUpdateFailed
147
-
148
- Fired when an app update fails.
149
-
150
- ```typescript
151
- NativeUpdate.addListener('appUpdateFailed', (error) => {
152
- console.error('Update failed:', error.error);
153
- });
154
- ```
155
-
156
- **Event Data:**
157
- ```typescript
158
- {
159
- error: string; // Error message
160
- code: string; // Error code
161
- }
162
- ```
163
-
164
- ### appUpdateNotificationClicked
165
-
166
- Fired when the user clicks on an update notification.
167
-
168
- ```typescript
169
- NativeUpdate.addListener('appUpdateNotificationClicked', () => {
170
- console.log('User clicked update notification');
171
- // Navigate to update screen
172
- });
173
- ```
174
-
175
- **Event Data:** Empty object `{}`
176
-
177
- ### appUpdateInstallClicked
178
-
179
- Fired when the user clicks the install button in an update notification.
180
-
181
- ```typescript
182
- NativeUpdate.addListener('appUpdateInstallClicked', () => {
183
- console.log('User clicked install in notification');
184
- // Start update installation
185
- });
186
- ```
187
-
188
- **Event Data:** Empty object `{}`
189
-
190
- ## Background Update Events
191
-
192
- ### backgroundUpdateProgress
193
-
194
- Fired during background update operations.
195
-
196
- ```typescript
197
- NativeUpdate.addListener('backgroundUpdateProgress', (event) => {
198
- console.log('Background update status:', event.status);
199
- });
200
- ```
201
-
202
- **Event Data:**
203
- ```typescript
204
- {
205
- type: BackgroundUpdateType;
206
- status: 'checking' | 'downloading' | 'installing' | 'completed' | 'failed';
207
- progress?: number;
208
- error?: string;
209
- }
210
- ```
211
-
212
- ### backgroundUpdateNotification
213
-
214
- Fired when background update has a notification to show.
215
-
216
- ```typescript
217
- NativeUpdate.addListener('backgroundUpdateNotification', (event) => {
218
- console.log('Update available:', event.updateAvailable);
219
- });
220
- ```
221
-
222
- **Event Data:**
223
- ```typescript
224
- {
225
- type: BackgroundUpdateType;
226
- updateAvailable: boolean;
227
- version?: string;
228
- description?: string;
229
- }
230
- ```
231
-
232
- ## Event Best Practices
233
-
234
- ### 1. Always Remove Listeners
235
-
236
- ```typescript
237
- class UpdateManager {
238
- private listeners: PluginListenerHandle[] = [];
239
-
240
- setupListeners() {
241
- // Store listener references
242
- this.listeners.push(
243
- NativeUpdate.addListener('updateStateChanged', (state) => {
244
- this.handleStateChange(state);
245
- })
246
- );
247
-
248
- this.listeners.push(
249
- NativeUpdate.addListener('downloadProgress', (progress) => {
250
- this.updateProgressBar(progress.percent);
251
- })
252
- );
253
- }
254
-
255
- cleanup() {
256
- // Remove all listeners
257
- this.listeners.forEach(listener => listener.remove());
258
- this.listeners = [];
259
- }
260
- }
261
- ```
262
-
263
- ### 2. Handle All States
264
-
265
- ```typescript
266
- function handleStateChange(state: UpdateStateChangedEvent) {
267
- switch (state.status) {
268
- case 'CHECKING':
269
- showLoader('Checking for updates...');
270
- break;
271
- case 'DOWNLOADING':
272
- showLoader('Downloading update...');
273
- break;
274
- case 'READY':
275
- hideLoader();
276
- promptUserToRestart();
277
- break;
278
- case 'FAILED':
279
- hideLoader();
280
- showError('Update failed. Please try again.');
281
- break;
282
- case 'INSTALLING':
283
- showLoader('Installing update...');
284
- break;
285
- }
286
- }
287
- ```
288
-
289
- ### 3. Progress Updates
290
-
291
- ```typescript
292
- function setupProgressTracking() {
293
- let lastUpdate = 0;
294
-
295
- NativeUpdate.addListener('downloadProgress', (progress) => {
296
- // Update UI at most once per second
297
- const now = Date.now();
298
- if (now - lastUpdate > 1000) {
299
- updateUI({
300
- percent: progress.percent,
301
- speed: formatBytes(progress.bytesPerSecond) + '/s',
302
- remaining: formatTime(progress.estimatedTime)
303
- });
304
- lastUpdate = now;
305
- }
306
- });
307
- }
308
- ```
309
-
310
- ## Platform-Specific Notes
311
-
312
- ### iOS
313
- - All events are supported
314
- - Review events may not fire if StoreKit decides not to show the prompt
315
-
316
- ### Android
317
- - All events are supported
318
- - App update events only fire when using Google Play
319
-
320
- ### Web
321
- - Limited event support
322
- - No native app update events
323
- - Review events will not fire