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,695 +0,0 @@
1
- # Native App Updates Implementation Guide
2
-
3
- This comprehensive guide explains how to implement Native App Updates (App Store and Google Play updates) in your Capacitor application using the NativeUpdate plugin.
4
-
5
- ## Table of Contents
6
-
7
- - [Overview](#overview)
8
- - [Platform Differences](#platform-differences)
9
- - [Setup Guide](#setup-guide)
10
- - [Implementation Steps](#implementation-steps)
11
- - [UI/UX Best Practices](#uiux-best-practices)
12
- - [Testing](#testing)
13
- - [Troubleshooting](#troubleshooting)
14
-
15
- ## Overview
16
-
17
- Native App Updates allow your app to:
18
-
19
- - 🔄 Check for new versions in app stores
20
- - 📥 Download updates within the app
21
- - 🚀 Install updates seamlessly
22
- - 📊 Track update adoption rates
23
-
24
- ### Benefits
25
-
26
- - **User Experience**: Users update without leaving your app
27
- - **Adoption Rate**: Higher update rates vs waiting for manual updates
28
- - **Control**: Guide users through important updates
29
- - **Flexibility**: Immediate vs flexible update strategies
30
-
31
- ## Platform Differences
32
-
33
- ### Android (Google Play)
34
-
35
- - Uses Google Play Core Library
36
- - Supports In-App Updates API
37
- - Two update modes: Immediate and Flexible
38
- - Requires Google Play Store (not available on other stores)
39
-
40
- ### iOS (App Store)
41
-
42
- - Uses StoreKit framework
43
- - Redirects to App Store for download
44
- - Cannot install directly within app
45
- - Shows update availability only
46
-
47
- ## Setup Guide
48
-
49
- ### Prerequisites
50
-
51
- 1. **Android**:
52
- - App must be published on Google Play Store
53
- - Minimum API level 21 (Android 5.0)
54
- - Google Play Core library
55
-
56
- 2. **iOS**:
57
- - App must be published on Apple App Store
58
- - iOS 10.0 or higher
59
- - Valid App Store ID
60
-
61
- ### Installation
62
-
63
- ```bash
64
- yarn add native-update
65
- npx cap sync
66
- ```
67
-
68
- ### Android Configuration
69
-
70
- 1. **Add to `android/app/build.gradle`:**
71
-
72
- ```gradle
73
- dependencies {
74
- implementation 'com.google.android.play:core:2.1.0'
75
- implementation 'com.google.android.play:core-ktx:1.8.1'
76
- }
77
- ```
78
-
79
- 2. **Add to `AndroidManifest.xml`:**
80
-
81
- ```xml
82
- <uses-permission android:name="android.permission.INTERNET" />
83
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
84
- ```
85
-
86
- ### iOS Configuration
87
-
88
- 1. **Add to `Info.plist`:**
89
-
90
- ```xml
91
- <key>LSApplicationQueriesSchemes</key>
92
- <array>
93
- <string>itms-apps</string>
94
- </array>
95
- ```
96
-
97
- 2. **Enable Capabilities in Xcode:**
98
- - App Groups (for shared data)
99
- - Background Modes > Background fetch
100
-
101
- ## Implementation Steps
102
-
103
- ### Step 1: Basic Implementation
104
-
105
- ```typescript
106
- import { NativeUpdate } from 'native-update';
107
- import { Capacitor } from '@capacitor/core';
108
-
109
- export class NativeUpdateService {
110
- async checkForAppUpdate() {
111
- try {
112
- // Check current platform
113
- const platform = Capacitor.getPlatform();
114
-
115
- // Check for native app updates
116
- const result = await NativeUpdate.getAppUpdateInfo();
117
-
118
- if (result.updateAvailable) {
119
- console.log(`Update available: ${result.availableVersion}`);
120
- console.log(`Current version: ${result.currentVersion}`);
121
-
122
- // Handle based on update type
123
- if (result.immediateUpdateAllowed) {
124
- await this.performImmediateUpdate();
125
- } else if (result.flexibleUpdateAllowed) {
126
- await this.performFlexibleUpdate();
127
- } else if (platform === 'ios') {
128
- await this.redirectToAppStore();
129
- }
130
- }
131
- } catch (error) {
132
- console.error('Update check failed:', error);
133
- }
134
- }
135
- }
136
- ```
137
-
138
- ### Step 2: Android In-App Updates
139
-
140
- #### Immediate Update (Blocking)
141
-
142
- ```typescript
143
- export class AndroidImmediateUpdate {
144
- async performImmediateUpdate() {
145
- try {
146
- // Start immediate update
147
- const { started } = await NativeUpdate.performImmediateUpdate();
148
-
149
- if (started) {
150
- // The app will be restarted automatically after update
151
- console.log('Immediate update started');
152
- }
153
- } catch (error) {
154
- if (error.code === 'UPDATE_CANCELED') {
155
- // User canceled the update
156
- // For immediate updates, you might want to close the app
157
- await this.showMandatoryUpdateDialog();
158
- }
159
- }
160
- }
161
-
162
- async showMandatoryUpdateDialog() {
163
- const alert = await this.alertController.create({
164
- header: 'Update Required',
165
- message: 'This update is required to continue using the app.',
166
- backdropDismiss: false,
167
- buttons: [
168
- {
169
- text: 'Update',
170
- handler: () => {
171
- this.performImmediateUpdate();
172
- },
173
- },
174
- ],
175
- });
176
- await alert.present();
177
- }
178
- }
179
- ```
180
-
181
- #### Flexible Update (Non-blocking)
182
-
183
- ```typescript
184
- export class AndroidFlexibleUpdate {
185
- private updateDownloaded = false;
186
-
187
- async performFlexibleUpdate() {
188
- try {
189
- // Start flexible update
190
- await NativeUpdate.startFlexibleUpdate();
191
-
192
- // Listen for download progress
193
- NativeUpdate.addListener(
194
- 'appUpdateProgress',
195
- (progress) => {
196
- console.log(
197
- `Download progress: ${progress.bytesDownloaded} / ${progress.totalBytesToDownload}`
198
- );
199
- this.updateProgressUI(progress);
200
- }
201
- );
202
-
203
- // Listen for download completion
204
- NativeUpdate.addListener('updateStateChanged', (event) => {
205
- if (event.status === 'DOWNLOADED') {
206
- console.log('Update downloaded');
207
- this.updateDownloaded = true;
208
- this.showInstallPrompt();
209
- }
210
- });
211
- } catch (error) {
212
- console.error('Flexible update failed:', error);
213
- }
214
- }
215
-
216
- async showInstallPrompt() {
217
- const alert = await this.alertController.create({
218
- header: 'Update Ready',
219
- message:
220
- 'A new version has been downloaded. Would you like to install it now?',
221
- buttons: [
222
- {
223
- text: 'Later',
224
- role: 'cancel',
225
- handler: () => {
226
- // Install will happen on next app restart
227
- },
228
- },
229
- {
230
- text: 'Install',
231
- handler: () => {
232
- this.completeFlexibleUpdate();
233
- },
234
- },
235
- ],
236
- });
237
- await alert.present();
238
- }
239
-
240
- async completeFlexibleUpdate() {
241
- try {
242
- await NativeUpdate.completeFlexibleUpdate();
243
- // App will restart with new version
244
- } catch (error) {
245
- console.error('Failed to complete update:', error);
246
- }
247
- }
248
-
249
- updateProgressUI(progress: any) {
250
- const percent = Math.round(
251
- (progress.bytesDownloaded / progress.totalBytesToDownload) * 100
252
- );
253
-
254
- // Update your UI progress bar
255
- this.downloadProgress = percent;
256
- }
257
- }
258
- ```
259
-
260
- ### Step 3: iOS App Store Updates
261
-
262
- ```typescript
263
- export class iOSAppStoreUpdate {
264
- async checkAndPromptUpdate() {
265
- try {
266
- const result = await NativeUpdate.getAppUpdateInfo();
267
-
268
- if (result.updateAvailable) {
269
- await this.showiOSUpdateDialog(result);
270
- }
271
- } catch (error) {
272
- console.error('iOS update check failed:', error);
273
- }
274
- }
275
-
276
- async showiOSUpdateDialog(updateInfo: any) {
277
- const alert = await this.alertController.create({
278
- header: 'Update Available',
279
- message: `Version ${updateInfo.availableVersion} is available on the App Store.`,
280
- buttons: [
281
- {
282
- text: 'Later',
283
- role: 'cancel',
284
- },
285
- {
286
- text: 'Update',
287
- handler: () => {
288
- this.openAppStore();
289
- },
290
- },
291
- ],
292
- });
293
- await alert.present();
294
- }
295
-
296
- async openAppStore() {
297
- try {
298
- await NativeUpdate.openAppStore();
299
- } catch (error) {
300
- // Fallback to browser
301
- const appStoreUrl = `https://apps.apple.com/app/id${YOUR_APP_STORE_ID}`;
302
- window.open(appStoreUrl, '_system');
303
- }
304
- }
305
- }
306
- ```
307
-
308
- ### Step 4: Cross-Platform Implementation
309
-
310
- ```typescript
311
- import { Capacitor } from '@capacitor/core';
312
- import { NativeUpdate } from 'native-update';
313
-
314
- export class UnifiedUpdateService {
315
- private platform = Capacitor.getPlatform();
316
-
317
- async checkAndUpdateApp() {
318
- try {
319
- const updateInfo = await NativeUpdate.getAppUpdateInfo();
320
-
321
- if (!updateInfo.updateAvailable) {
322
- console.log('App is up to date');
323
- return;
324
- }
325
-
326
- // Platform-specific handling
327
- if (this.platform === 'android') {
328
- await this.handleAndroidUpdate(updateInfo);
329
- } else if (this.platform === 'ios') {
330
- await this.handleiOSUpdate(updateInfo);
331
- }
332
- } catch (error) {
333
- console.error('Update check failed:', error);
334
- this.handleUpdateError(error);
335
- }
336
- }
337
-
338
- private async handleAndroidUpdate(updateInfo: any) {
339
- // Determine update priority
340
- const priority = updateInfo.updatePriority || 0;
341
-
342
- if (priority >= 4 || updateInfo.immediateUpdateAllowed) {
343
- // High priority or immediate update required
344
- await this.showUpdateDialog({
345
- title: 'Important Update',
346
- message: 'A critical update is available and must be installed.',
347
- mandatory: true,
348
- action: () => this.performImmediateUpdate(),
349
- });
350
- } else if (updateInfo.flexibleUpdateAllowed) {
351
- // Normal priority - flexible update
352
- await this.showUpdateDialog({
353
- title: 'Update Available',
354
- message: `Version ${updateInfo.availableVersion} is available with new features and improvements.`,
355
- mandatory: false,
356
- action: () => this.performFlexibleUpdate(),
357
- });
358
- }
359
- }
360
-
361
- private async handleiOSUpdate(updateInfo: any) {
362
- await this.showUpdateDialog({
363
- title: 'Update Available',
364
- message: `Version ${updateInfo.availableVersion} is available on the App Store.`,
365
- mandatory: false,
366
- action: () => NativeUpdate.openAppStore(),
367
- });
368
- }
369
-
370
- private async showUpdateDialog(options: {
371
- title: string;
372
- message: string;
373
- mandatory: boolean;
374
- action: () => Promise<void>;
375
- }) {
376
- const buttons = options.mandatory
377
- ? [
378
- {
379
- text: 'Update Now',
380
- handler: () => options.action(),
381
- },
382
- ]
383
- : [
384
- {
385
- text: 'Later',
386
- role: 'cancel',
387
- },
388
- {
389
- text: 'Update',
390
- handler: () => options.action(),
391
- },
392
- ];
393
-
394
- const alert = await this.alertController.create({
395
- header: options.title,
396
- message: options.message,
397
- backdropDismiss: !options.mandatory,
398
- buttons,
399
- });
400
-
401
- await alert.present();
402
- }
403
- }
404
- ```
405
-
406
- ### Step 5: Update Status Handling
407
-
408
- ```typescript
409
- export class UpdateStatusManager {
410
- constructor() {
411
- this.setupUpdateListeners();
412
- }
413
-
414
- private setupUpdateListeners() {
415
- // Installation status
416
- NativeUpdate.addListener('updateStateChanged', (status) => {
417
- switch (status.status) {
418
- case 'PENDING':
419
- console.log('Update pending');
420
- break;
421
- case 'DOWNLOADING':
422
- console.log('Downloading update');
423
- break;
424
- case 'INSTALLING':
425
- console.log('Installing update');
426
- break;
427
- case 'INSTALLED':
428
- console.log('Update installed');
429
- this.notifyUpdateComplete();
430
- break;
431
- case 'FAILED':
432
- console.error('Update failed:', status.error);
433
- this.handleUpdateFailure(status.error);
434
- break;
435
- case 'CANCELED':
436
- console.log('Update canceled by user');
437
- break;
438
- }
439
- });
440
-
441
- // Download progress (Android flexible updates)
442
- NativeUpdate.addListener(
443
- 'onAppUpdateDownloadProgress',
444
- (progress) => {
445
- const percent = Math.round(
446
- (progress.bytesDownloaded / progress.totalBytesToDownload) * 100
447
- );
448
- this.updateProgressBar(percent);
449
- }
450
- );
451
- }
452
-
453
- private updateProgressBar(percent: number) {
454
- // Update your UI
455
- const progressBar = document.querySelector('.update-progress');
456
- if (progressBar) {
457
- progressBar.setAttribute('value', percent.toString());
458
- }
459
- }
460
- }
461
- ```
462
-
463
- ## UI/UX Best Practices
464
-
465
- ### 1. Update Prompts
466
-
467
- ```typescript
468
- export class UpdateUIService {
469
- async showSmartUpdatePrompt(updateInfo: any) {
470
- const timeSinceLastPrompt = Date.now() - this.lastPromptTime;
471
- const oneDayInMs = 24 * 60 * 60 * 1000;
472
-
473
- // Don't prompt too frequently
474
- if (timeSinceLastPrompt < oneDayInMs && !updateInfo.mandatory) {
475
- return;
476
- }
477
-
478
- // Custom UI based on update importance
479
- if (updateInfo.updatePriority >= 4) {
480
- await this.showCriticalUpdateUI(updateInfo);
481
- } else if (updateInfo.releaseNotes?.includes('security')) {
482
- await this.showSecurityUpdateUI(updateInfo);
483
- } else {
484
- await this.showStandardUpdateUI(updateInfo);
485
- }
486
-
487
- this.lastPromptTime = Date.now();
488
- }
489
-
490
- private async showCriticalUpdateUI(updateInfo: any) {
491
- // Full-screen modal for critical updates
492
- const modal = await this.modalController.create({
493
- component: CriticalUpdateComponent,
494
- componentProps: { updateInfo },
495
- backdropDismiss: false,
496
- });
497
- await modal.present();
498
- }
499
-
500
- private async showStandardUpdateUI(updateInfo: any) {
501
- // Toast or small banner for standard updates
502
- const toast = await this.toastController.create({
503
- message: 'A new version is available',
504
- duration: 5000,
505
- position: 'top',
506
- buttons: [
507
- {
508
- text: 'Update',
509
- handler: () => this.startUpdate(),
510
- },
511
- ],
512
- });
513
- await toast.present();
514
- }
515
- }
516
- ```
517
-
518
- ### 2. Progress Indicators
519
-
520
- ```html
521
- <!-- update-progress.component.html -->
522
- <ion-card *ngIf="updateInProgress">
523
- <ion-card-header>
524
- <ion-card-title>Updating App</ion-card-title>
525
- </ion-card-header>
526
- <ion-card-content>
527
- <ion-progress-bar [value]="downloadProgress / 100"></ion-progress-bar>
528
- <p>{{ downloadProgress }}% complete</p>
529
- <p class="update-status">{{ updateStatus }}</p>
530
- </ion-card-content>
531
- </ion-card>
532
- ```
533
-
534
- ### 3. Smart Update Scheduling
535
-
536
- ```typescript
537
- export class SmartUpdateScheduler {
538
- async scheduleUpdate() {
539
- const updateInfo = await NativeUpdate.getAppUpdateInfo();
540
-
541
- if (!updateInfo.updateAvailable) return;
542
-
543
- // Check user preferences
544
- const preferences = await this.getUpdatePreferences();
545
-
546
- if (preferences.autoUpdate === 'wifi-only') {
547
- const connection = await Network.getStatus();
548
- if (connection.connectionType !== 'wifi') {
549
- // Schedule for later when on WiFi
550
- this.scheduleForWiFi();
551
- return;
552
- }
553
- }
554
-
555
- if (preferences.autoUpdate === 'night-only') {
556
- const hour = new Date().getHours();
557
- if (hour >= 6 && hour <= 22) {
558
- // Schedule for nighttime
559
- this.scheduleForNight();
560
- return;
561
- }
562
- }
563
-
564
- // Proceed with update
565
- await this.performUpdate();
566
- }
567
- }
568
- ```
569
-
570
- ## Testing
571
-
572
- ### Android Testing
573
-
574
- 1. **Using Internal Test Track**:
575
-
576
- ```typescript
577
- // Enable internal app sharing for testing
578
- await NativeUpdate.enableDebugMode({
579
- enabled: true,
580
- testMode: 'internal-test',
581
- });
582
- ```
583
-
584
- 2. **Test Different Scenarios**:
585
-
586
- ```typescript
587
- // Test immediate update
588
- await NativeUpdate.simulateUpdate({
589
- type: 'immediate',
590
- version: '2.0.0',
591
- });
592
-
593
- // Test flexible update
594
- await NativeUpdate.simulateUpdate({
595
- type: 'flexible',
596
- version: '1.1.0',
597
- });
598
- ```
599
-
600
- ### iOS Testing
601
-
602
- 1. **TestFlight Testing**:
603
- - Upload build to TestFlight
604
- - Install older version on device
605
- - Check for updates in app
606
-
607
- 2. **Sandbox Testing**:
608
- - Use sandbox App Store account
609
- - Test update flow without affecting production
610
-
611
- ### Testing Checklist
612
-
613
- - [ ] Update available detection
614
- - [ ] Update not available scenario
615
- - [ ] Immediate update flow (Android)
616
- - [ ] Flexible update flow (Android)
617
- - [ ] App Store redirect (iOS)
618
- - [ ] Update cancellation handling
619
- - [ ] Network error handling
620
- - [ ] Update completion verification
621
- - [ ] Rollback scenarios (if applicable)
622
-
623
- ## Troubleshooting
624
-
625
- ### Common Issues
626
-
627
- #### 1. Update Not Detected
628
-
629
- ```typescript
630
- // Debug update detection
631
- const debug = await NativeUpdate.getDebugInfo();
632
- console.log('Debug info:', {
633
- currentVersion: debug.currentVersion,
634
- packageName: debug.packageName,
635
- lastCheckTime: debug.lastCheckTime,
636
- playServicesAvailable: debug.playServicesAvailable, // Android
637
- });
638
- ```
639
-
640
- #### 2. Update Fails to Install
641
-
642
- ```typescript
643
- // Check update state
644
- const state = await NativeUpdate.getUpdateState();
645
- if (state.status === 'FAILED') {
646
- // Clear update data and retry
647
- await NativeUpdate.clearUpdateData();
648
- await NativeUpdate.getAppUpdateInfo();
649
- }
650
- ```
651
-
652
- #### 3. iOS App Store Not Opening
653
-
654
- ```typescript
655
- // App Store ID is configured in capacitor.config.json
656
- // Check your configuration file for the appStoreId setting
657
-
658
- // Manual fallback
659
- if (!config.appStoreId) {
660
- console.error('App Store ID not configured');
661
- }
662
- ```
663
-
664
- ### Platform-Specific Issues
665
-
666
- #### Android
667
-
668
- - Ensure Google Play Services is updated
669
- - Check Play Store app is installed
670
- - Verify app is signed with release key
671
- - Test on device with Play Store (not emulator)
672
-
673
- #### iOS
674
-
675
- - Verify App Store ID is correct
676
- - Check iTunes lookup API response
677
- - Ensure app is live on App Store
678
- - Test on real device (not simulator)
679
-
680
- ## Best Practices Summary
681
-
682
- 1. **Always provide "Later" option** for non-critical updates
683
- 2. **Show release notes** when available
684
- 3. **Respect user preferences** for update timing
685
- 4. **Handle network conditions** appropriately
686
- 5. **Test thoroughly** on both platforms
687
- 6. **Monitor update metrics** to improve adoption
688
- 7. **Provide fallback options** for update failures
689
-
690
- ## Next Steps
691
-
692
- - Learn about [Live Updates (OTA)](https://nativeupdate.aoneahsan.com/docs/LIVE_UPDATES_GUIDE)
693
- - Implement [App Review Features](https://nativeupdate.aoneahsan.com/docs/APP_REVIEW_GUIDE)
694
- - Review [Security Guidelines](https://nativeupdate.aoneahsan.com/docs/guides/security-best-practices)
695
- - Check [API Reference](https://nativeupdate.aoneahsan.com/docs/api/app-update-api)