native-update 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/CapacitorNativeUpdate.podspec +18 -0
  2. package/LICENSE +21 -0
  3. package/Readme.md +451 -0
  4. package/android/build.gradle +92 -0
  5. package/android/gradle/wrapper/gradle-wrapper.properties +8 -0
  6. package/android/gradle.properties +17 -0
  7. package/android/proguard-rules.pro +29 -0
  8. package/android/settings.gradle +2 -0
  9. package/android/src/main/AndroidManifest.xml +34 -0
  10. package/android/src/main/java/com/aoneahsan/nativeupdate/AppReviewPlugin.kt +153 -0
  11. package/android/src/main/java/com/aoneahsan/nativeupdate/AppUpdatePlugin.kt +275 -0
  12. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundNotificationManager.kt +390 -0
  13. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateManager.kt +46 -0
  14. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdatePlugin.kt +333 -0
  15. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateWorker.kt +251 -0
  16. package/android/src/main/java/com/aoneahsan/nativeupdate/CapacitorNativeUpdatePlugin.kt +265 -0
  17. package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +526 -0
  18. package/android/src/main/java/com/aoneahsan/nativeupdate/NotificationActionReceiver.kt +99 -0
  19. package/android/src/main/java/com/aoneahsan/nativeupdate/SecurityManager.kt +249 -0
  20. package/dist/esm/__tests__/bundle-manager.test.d.ts +1 -0
  21. package/dist/esm/__tests__/bundle-manager.test.js +123 -0
  22. package/dist/esm/__tests__/bundle-manager.test.js.map +1 -0
  23. package/dist/esm/__tests__/config.test.d.ts +1 -0
  24. package/dist/esm/__tests__/config.test.js +69 -0
  25. package/dist/esm/__tests__/config.test.js.map +1 -0
  26. package/dist/esm/__tests__/integration.test.d.ts +1 -0
  27. package/dist/esm/__tests__/integration.test.js +78 -0
  28. package/dist/esm/__tests__/integration.test.js.map +1 -0
  29. package/dist/esm/__tests__/security.test.d.ts +1 -0
  30. package/dist/esm/__tests__/security.test.js +54 -0
  31. package/dist/esm/__tests__/security.test.js.map +1 -0
  32. package/dist/esm/__tests__/version-manager.test.d.ts +1 -0
  33. package/dist/esm/__tests__/version-manager.test.js +45 -0
  34. package/dist/esm/__tests__/version-manager.test.js.map +1 -0
  35. package/dist/esm/app-review/app-review-manager.d.ts +24 -0
  36. package/dist/esm/app-review/app-review-manager.js +195 -0
  37. package/dist/esm/app-review/app-review-manager.js.map +1 -0
  38. package/dist/esm/app-review/index.d.ts +5 -0
  39. package/dist/esm/app-review/index.js +6 -0
  40. package/dist/esm/app-review/index.js.map +1 -0
  41. package/dist/esm/app-review/platform-review-handler.d.ts +20 -0
  42. package/dist/esm/app-review/platform-review-handler.js +138 -0
  43. package/dist/esm/app-review/platform-review-handler.js.map +1 -0
  44. package/dist/esm/app-review/review-conditions-checker.d.ts +22 -0
  45. package/dist/esm/app-review/review-conditions-checker.js +155 -0
  46. package/dist/esm/app-review/review-conditions-checker.js.map +1 -0
  47. package/dist/esm/app-review/review-rate-limiter.d.ts +23 -0
  48. package/dist/esm/app-review/review-rate-limiter.js +164 -0
  49. package/dist/esm/app-review/review-rate-limiter.js.map +1 -0
  50. package/dist/esm/app-review/types.d.ts +41 -0
  51. package/dist/esm/app-review/types.js +2 -0
  52. package/dist/esm/app-review/types.js.map +1 -0
  53. package/dist/esm/app-update/app-update-checker.d.ts +13 -0
  54. package/dist/esm/app-update/app-update-checker.js +104 -0
  55. package/dist/esm/app-update/app-update-checker.js.map +1 -0
  56. package/dist/esm/app-update/app-update-installer.d.ts +19 -0
  57. package/dist/esm/app-update/app-update-installer.js +123 -0
  58. package/dist/esm/app-update/app-update-installer.js.map +1 -0
  59. package/dist/esm/app-update/app-update-manager.d.ts +28 -0
  60. package/dist/esm/app-update/app-update-manager.js +199 -0
  61. package/dist/esm/app-update/app-update-manager.js.map +1 -0
  62. package/dist/esm/app-update/app-update-notifier.d.ts +14 -0
  63. package/dist/esm/app-update/app-update-notifier.js +100 -0
  64. package/dist/esm/app-update/app-update-notifier.js.map +1 -0
  65. package/dist/esm/app-update/index.d.ts +6 -0
  66. package/dist/esm/app-update/index.js +7 -0
  67. package/dist/esm/app-update/index.js.map +1 -0
  68. package/dist/esm/app-update/platform-app-update.d.ts +19 -0
  69. package/dist/esm/app-update/platform-app-update.js +129 -0
  70. package/dist/esm/app-update/platform-app-update.js.map +1 -0
  71. package/dist/esm/app-update/types.d.ts +58 -0
  72. package/dist/esm/app-update/types.js +12 -0
  73. package/dist/esm/app-update/types.js.map +1 -0
  74. package/dist/esm/background-update/background-scheduler.d.ts +17 -0
  75. package/dist/esm/background-update/background-scheduler.js +195 -0
  76. package/dist/esm/background-update/background-scheduler.js.map +1 -0
  77. package/dist/esm/background-update/index.d.ts +3 -0
  78. package/dist/esm/background-update/index.js +3 -0
  79. package/dist/esm/background-update/index.js.map +1 -0
  80. package/dist/esm/background-update/notification-manager.d.ts +29 -0
  81. package/dist/esm/background-update/notification-manager.js +89 -0
  82. package/dist/esm/background-update/notification-manager.js.map +1 -0
  83. package/dist/esm/core/analytics.d.ts +70 -0
  84. package/dist/esm/core/analytics.js +137 -0
  85. package/dist/esm/core/analytics.js.map +1 -0
  86. package/dist/esm/core/cache-manager.d.ts +72 -0
  87. package/dist/esm/core/cache-manager.js +275 -0
  88. package/dist/esm/core/cache-manager.js.map +1 -0
  89. package/dist/esm/core/config.d.ts +48 -0
  90. package/dist/esm/core/config.js +83 -0
  91. package/dist/esm/core/config.js.map +1 -0
  92. package/dist/esm/core/errors.d.ts +51 -0
  93. package/dist/esm/core/errors.js +80 -0
  94. package/dist/esm/core/errors.js.map +1 -0
  95. package/dist/esm/core/logger.d.ts +21 -0
  96. package/dist/esm/core/logger.js +109 -0
  97. package/dist/esm/core/logger.js.map +1 -0
  98. package/dist/esm/core/performance.d.ts +53 -0
  99. package/dist/esm/core/performance.js +140 -0
  100. package/dist/esm/core/performance.js.map +1 -0
  101. package/dist/esm/core/plugin-manager.d.ts +66 -0
  102. package/dist/esm/core/plugin-manager.js +148 -0
  103. package/dist/esm/core/plugin-manager.js.map +1 -0
  104. package/dist/esm/core/security.d.ts +93 -0
  105. package/dist/esm/core/security.js +315 -0
  106. package/dist/esm/core/security.js.map +1 -0
  107. package/dist/esm/definitions.d.ts +639 -0
  108. package/dist/esm/definitions.js +103 -0
  109. package/dist/esm/definitions.js.map +1 -0
  110. package/dist/esm/index.d.ts +12 -0
  111. package/dist/esm/index.js +16 -0
  112. package/dist/esm/index.js.map +1 -0
  113. package/dist/esm/live-update/bundle-manager.d.ts +94 -0
  114. package/dist/esm/live-update/bundle-manager.js +310 -0
  115. package/dist/esm/live-update/bundle-manager.js.map +1 -0
  116. package/dist/esm/live-update/certificate-pinning.d.ts +38 -0
  117. package/dist/esm/live-update/certificate-pinning.js +78 -0
  118. package/dist/esm/live-update/certificate-pinning.js.map +1 -0
  119. package/dist/esm/live-update/download-manager.d.ts +67 -0
  120. package/dist/esm/live-update/download-manager.js +319 -0
  121. package/dist/esm/live-update/download-manager.js.map +1 -0
  122. package/dist/esm/live-update/update-manager.d.ts +52 -0
  123. package/dist/esm/live-update/update-manager.js +294 -0
  124. package/dist/esm/live-update/update-manager.js.map +1 -0
  125. package/dist/esm/live-update/version-manager.d.ts +84 -0
  126. package/dist/esm/live-update/version-manager.js +335 -0
  127. package/dist/esm/live-update/version-manager.js.map +1 -0
  128. package/dist/esm/plugin.d.ts +6 -0
  129. package/dist/esm/plugin.js +283 -0
  130. package/dist/esm/plugin.js.map +1 -0
  131. package/dist/esm/security/crypto.d.ts +25 -0
  132. package/dist/esm/security/crypto.js +70 -0
  133. package/dist/esm/security/crypto.js.map +1 -0
  134. package/dist/esm/security/validator.d.ts +60 -0
  135. package/dist/esm/security/validator.js +143 -0
  136. package/dist/esm/security/validator.js.map +1 -0
  137. package/dist/esm/web.d.ts +74 -0
  138. package/dist/esm/web.js +595 -0
  139. package/dist/esm/web.js.map +1 -0
  140. package/dist/plugin.cjs.js +2 -0
  141. package/dist/plugin.cjs.js.map +1 -0
  142. package/dist/plugin.esm.js +2 -0
  143. package/dist/plugin.esm.js.map +1 -0
  144. package/dist/plugin.js +3 -0
  145. package/dist/plugin.js.map +1 -0
  146. package/docs/APP_REVIEW_GUIDE.md +768 -0
  147. package/docs/BUNDLE_SIGNING.md +264 -0
  148. package/docs/LIVE_UPDATES_GUIDE.md +650 -0
  149. package/docs/MIGRATION.md +192 -0
  150. package/docs/NATIVE_UPDATES_GUIDE.md +694 -0
  151. package/docs/QUICK_START.md +606 -0
  152. package/docs/README.md +111 -0
  153. package/docs/REMAINING_FEATURES.md +139 -0
  154. package/docs/api/app-review-api.md +259 -0
  155. package/docs/api/app-update-api.md +238 -0
  156. package/docs/api/events-api.md +451 -0
  157. package/docs/api/live-update-api.md +265 -0
  158. package/docs/background-updates.md +392 -0
  159. package/docs/examples/advanced-scenarios.md +410 -0
  160. package/docs/examples/basic-usage.md +185 -0
  161. package/docs/features/app-reviews.md +975 -0
  162. package/docs/features/app-updates.md +785 -0
  163. package/docs/features/live-updates.md +633 -0
  164. package/docs/getting-started/configuration.md +468 -0
  165. package/docs/getting-started/installation.md +209 -0
  166. package/docs/getting-started/quick-start.md +379 -0
  167. package/docs/guides/deployment-guide.md +333 -0
  168. package/docs/guides/migration-from-codepush.md +142 -0
  169. package/docs/guides/security-best-practices.md +1057 -0
  170. package/docs/guides/testing-guide.md +373 -0
  171. package/docs/production-readiness.md +478 -0
  172. package/docs/security/certificate-pinning.md +122 -0
  173. package/docs/server-requirements.md +147 -0
  174. package/ios/Plugin/AppReview/AppReviewPlugin.swift +158 -0
  175. package/ios/Plugin/AppUpdate/AppUpdatePlugin.swift +234 -0
  176. package/ios/Plugin/BackgroundUpdate/BackgroundNotificationManager.swift +329 -0
  177. package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +396 -0
  178. package/ios/Plugin/CapacitorNativeUpdatePlugin.m +45 -0
  179. package/ios/Plugin/CapacitorNativeUpdatePlugin.swift +190 -0
  180. package/ios/Plugin/Info.plist +43 -0
  181. package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +689 -0
  182. package/ios/Plugin/LiveUpdate/WebViewConfiguration.swift +45 -0
  183. package/ios/Plugin/Security/SecurityManager.swift +289 -0
  184. package/package.json +90 -0
@@ -0,0 +1,392 @@
1
+ # Background Update Feature
2
+
3
+ The Background Update feature allows your app to check for updates automatically while running in the background, providing a seamless user experience with native notifications.
4
+
5
+ ## Features
6
+
7
+ ### Core Functionality
8
+
9
+ - **Background Update Checking**: Automatically check for app and live updates while the app is not active
10
+ - **Native Notifications**: Send native device notifications when updates are available
11
+ - **Configurable Intervals**: Set custom check intervals and update types
12
+ - **Battery Optimization**: Respect system battery saving modes and constraints
13
+ - **Cross-Platform**: Works on iOS (BGTaskScheduler) and Android (WorkManager)
14
+
15
+ ### Platform-Specific Implementation
16
+
17
+ - **iOS**: Uses BGTaskScheduler for background tasks and UNUserNotificationCenter for notifications
18
+ - **Android**: Uses WorkManager for background processing and NotificationManager for notifications
19
+ - **Web**: Uses Notification API and intervals for fallback functionality
20
+
21
+ ## Configuration
22
+
23
+ ### Basic Setup
24
+
25
+ ```typescript
26
+ import {
27
+ CapacitorNativeUpdate,
28
+ BackgroundUpdateType,
29
+ } from 'capacitor-native-update';
30
+
31
+ // Configure the plugin with background updates
32
+ await CapacitorNativeUpdate.configure({
33
+ backgroundUpdate: {
34
+ enabled: true,
35
+ checkInterval: 24 * 60 * 60 * 1000, // 24 hours
36
+ updateTypes: [BackgroundUpdateType.BOTH],
37
+ autoInstall: false,
38
+ respectBatteryOptimization: true,
39
+ requireWifi: false,
40
+ notificationPreferences: {
41
+ title: 'App Update Available',
42
+ description: 'A new version is ready to install',
43
+ soundEnabled: true,
44
+ vibrationEnabled: true,
45
+ showActions: true,
46
+ actionLabels: {
47
+ updateNow: 'Update Now',
48
+ updateLater: 'Later',
49
+ dismiss: 'Not Now',
50
+ },
51
+ },
52
+ },
53
+ });
54
+ ```
55
+
56
+ ### Advanced Configuration
57
+
58
+ ```typescript
59
+ // Advanced background update configuration
60
+ await CapacitorNativeUpdate.configure({
61
+ backgroundUpdate: {
62
+ enabled: true,
63
+ checkInterval: 12 * 60 * 60 * 1000, // 12 hours
64
+ updateTypes: [
65
+ BackgroundUpdateType.APP_UPDATE,
66
+ BackgroundUpdateType.LIVE_UPDATE,
67
+ ],
68
+ autoInstall: true, // Only for live updates
69
+ respectBatteryOptimization: true,
70
+ allowMeteredConnection: false,
71
+ minimumBatteryLevel: 20,
72
+ requireWifi: true,
73
+ maxRetries: 3,
74
+ retryDelay: 5000,
75
+ notificationPreferences: {
76
+ title: 'MyApp Update',
77
+ description: 'New features and improvements are available',
78
+ iconName: 'update_icon',
79
+ soundEnabled: true,
80
+ vibrationEnabled: true,
81
+ showActions: true,
82
+ channelId: 'app_updates',
83
+ channelName: 'App Updates',
84
+ priority: 'high',
85
+ actionLabels: {
86
+ updateNow: 'Install Now',
87
+ updateLater: 'Remind Me Later',
88
+ dismiss: 'Skip This Version',
89
+ },
90
+ },
91
+ },
92
+ });
93
+ ```
94
+
95
+ ## API Methods
96
+
97
+ ### Enable Background Updates
98
+
99
+ ```typescript
100
+ await CapacitorNativeUpdate.enableBackgroundUpdates({
101
+ enabled: true,
102
+ checkInterval: 24 * 60 * 60 * 1000,
103
+ updateTypes: [BackgroundUpdateType.BOTH],
104
+ });
105
+ ```
106
+
107
+ ### Disable Background Updates
108
+
109
+ ```typescript
110
+ await CapacitorNativeUpdate.disableBackgroundUpdates();
111
+ ```
112
+
113
+ ### Get Background Update Status
114
+
115
+ ```typescript
116
+ const status = await CapacitorNativeUpdate.getBackgroundUpdateStatus();
117
+ console.log('Background updates enabled:', status.enabled);
118
+ console.log('Last check:', new Date(status.lastCheckTime));
119
+ console.log('Next check:', new Date(status.nextCheckTime));
120
+ ```
121
+
122
+ ### Trigger Manual Check
123
+
124
+ ```typescript
125
+ const result = await CapacitorNativeUpdate.triggerBackgroundCheck();
126
+ if (result.updatesFound) {
127
+ console.log('Updates found!', result.appUpdate, result.liveUpdate);
128
+ }
129
+ ```
130
+
131
+ ### Configure Notifications
132
+
133
+ ```typescript
134
+ // Set notification preferences
135
+ await CapacitorNativeUpdate.setNotificationPreferences({
136
+ title: 'Custom Update Title',
137
+ description: 'Custom update message',
138
+ soundEnabled: true,
139
+ vibrationEnabled: true,
140
+ showActions: true,
141
+ actionLabels: {
142
+ updateNow: 'Install',
143
+ updateLater: 'Later',
144
+ dismiss: 'Skip',
145
+ },
146
+ });
147
+
148
+ // Request notification permissions
149
+ const granted = await CapacitorNativeUpdate.requestNotificationPermissions();
150
+ if (granted) {
151
+ console.log('Notification permissions granted');
152
+ }
153
+
154
+ // Check permission status
155
+ const permissions = await CapacitorNativeUpdate.getNotificationPermissions();
156
+ console.log('Permissions granted:', permissions.granted);
157
+ ```
158
+
159
+ ## Event Listeners
160
+
161
+ ### Background Update Progress
162
+
163
+ ```typescript
164
+ CapacitorNativeUpdate.addListener('backgroundUpdateProgress', (event) => {
165
+ console.log('Background update progress:', event.status, event.percent);
166
+ });
167
+ ```
168
+
169
+ ### Background Update Notifications
170
+
171
+ ```typescript
172
+ CapacitorNativeUpdate.addListener('backgroundUpdateNotification', (event) => {
173
+ console.log('Notification action:', event.action);
174
+
175
+ switch (event.action) {
176
+ case 'tapped':
177
+ // User tapped notification
178
+ break;
179
+ case 'update_now':
180
+ // User chose to update now
181
+ break;
182
+ case 'update_later':
183
+ // User chose to update later
184
+ break;
185
+ case 'dismiss':
186
+ // User dismissed notification
187
+ break;
188
+ }
189
+ });
190
+ ```
191
+
192
+ ## Platform-Specific Setup
193
+
194
+ ### iOS Setup
195
+
196
+ Add to your `Info.plist`:
197
+
198
+ ```xml
199
+ <key>UIBackgroundModes</key>
200
+ <array>
201
+ <string>background-app-refresh</string>
202
+ <string>background-processing</string>
203
+ </array>
204
+ <key>BGTaskSchedulerPermittedIdentifiers</key>
205
+ <array>
206
+ <string>com.aoneahsan.nativeupdate.background</string>
207
+ </array>
208
+ ```
209
+
210
+ ### Android Setup
211
+
212
+ Add to your `AndroidManifest.xml`:
213
+
214
+ ```xml
215
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
216
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
217
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
218
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
219
+ ```
220
+
221
+ ## Best Practices
222
+
223
+ ### Battery Optimization
224
+
225
+ - Set `respectBatteryOptimization: true` to work within system constraints
226
+ - Use reasonable check intervals (not less than 15 minutes)
227
+ - Consider `requireWifi: true` for large updates
228
+
229
+ ### User Experience
230
+
231
+ - Always request notification permissions before enabling background updates
232
+ - Provide clear notification messages and actions
233
+ - Handle notification actions appropriately
234
+ - Allow users to disable background updates in settings
235
+
236
+ ### Performance
237
+
238
+ - Use `BackgroundUpdateType.APP_UPDATE` for critical updates only
239
+ - Use `BackgroundUpdateType.LIVE_UPDATE` for content updates
240
+ - Use `BackgroundUpdateType.BOTH` sparingly to avoid excessive battery usage
241
+
242
+ ## Error Handling
243
+
244
+ ```typescript
245
+ try {
246
+ await CapacitorNativeUpdate.enableBackgroundUpdates(config);
247
+ } catch (error) {
248
+ console.error('Failed to enable background updates:', error);
249
+ }
250
+
251
+ // Listen for background update errors
252
+ CapacitorNativeUpdate.addListener('backgroundUpdateProgress', (event) => {
253
+ if (event.status === 'failed' && event.error) {
254
+ console.error('Background update failed:', event.error);
255
+ }
256
+ });
257
+ ```
258
+
259
+ ## Configuration Options
260
+
261
+ ### BackgroundUpdateConfig
262
+
263
+ | Option | Type | Default | Description |
264
+ | ---------------------------- | ---------------------- | ---------- | ----------------------------------------- |
265
+ | `enabled` | boolean | `false` | Enable/disable background updates |
266
+ | `checkInterval` | number | `86400000` | Check interval in milliseconds (24 hours) |
267
+ | `updateTypes` | BackgroundUpdateType[] | `['both']` | Types of updates to check for |
268
+ | `autoInstall` | boolean | `false` | Auto-install updates (live updates only) |
269
+ | `respectBatteryOptimization` | boolean | `true` | Respect system battery optimization |
270
+ | `allowMeteredConnection` | boolean | `false` | Allow updates on metered connections |
271
+ | `minimumBatteryLevel` | number | `20` | Minimum battery level (%) |
272
+ | `requireWifi` | boolean | `false` | Require WiFi connection |
273
+ | `maxRetries` | number | `3` | Maximum retry attempts |
274
+ | `retryDelay` | number | `5000` | Retry delay in milliseconds |
275
+
276
+ ### NotificationPreferences
277
+
278
+ | Option | Type | Default | Description |
279
+ | ------------------ | ------- | ------------------------------ | -------------------------------- |
280
+ | `title` | string | `'App Update Available'` | Notification title |
281
+ | `description` | string | `'A new version is available'` | Notification description |
282
+ | `soundEnabled` | boolean | `true` | Enable notification sound |
283
+ | `vibrationEnabled` | boolean | `true` | Enable notification vibration |
284
+ | `showActions` | boolean | `true` | Show notification action buttons |
285
+ | `priority` | string | `'default'` | Notification priority |
286
+ | `actionLabels` | object | See defaults | Custom action button labels |
287
+
288
+ ## Troubleshooting
289
+
290
+ ### iOS Issues
291
+
292
+ - Ensure background app refresh is enabled in device settings
293
+ - Check that the app has notification permissions
294
+ - Verify BGTaskScheduler identifiers in Info.plist
295
+
296
+ ### Android Issues
297
+
298
+ - Check that the app is not in battery optimization whitelist
299
+ - Ensure notification permissions are granted
300
+ - Verify WorkManager dependencies are included
301
+
302
+ ### Common Issues
303
+
304
+ - Background tasks may be limited by the OS
305
+ - Notifications may not work without proper permissions
306
+ - Battery optimization can prevent background execution
307
+
308
+ ## Example Implementation
309
+
310
+ ```typescript
311
+ class BackgroundUpdateManager {
312
+ private isInitialized = false;
313
+
314
+ async initialize() {
315
+ if (this.isInitialized) return;
316
+
317
+ // Request notification permissions first
318
+ const granted =
319
+ await CapacitorNativeUpdate.requestNotificationPermissions();
320
+ if (!granted) {
321
+ console.warn('Notification permissions not granted');
322
+ return;
323
+ }
324
+
325
+ // Configure background updates
326
+ await CapacitorNativeUpdate.configure({
327
+ backgroundUpdate: {
328
+ enabled: true,
329
+ checkInterval: 24 * 60 * 60 * 1000, // 24 hours
330
+ updateTypes: [BackgroundUpdateType.BOTH],
331
+ autoInstall: false,
332
+ respectBatteryOptimization: true,
333
+ notificationPreferences: {
334
+ title: 'MyApp Update',
335
+ description: 'New features are available',
336
+ showActions: true,
337
+ actionLabels: {
338
+ updateNow: 'Install Now',
339
+ updateLater: 'Later',
340
+ dismiss: 'Skip',
341
+ },
342
+ },
343
+ },
344
+ });
345
+
346
+ // Set up event listeners
347
+ CapacitorNativeUpdate.addListener(
348
+ 'backgroundUpdateNotification',
349
+ (event) => {
350
+ this.handleNotificationAction(event.action);
351
+ }
352
+ );
353
+
354
+ this.isInitialized = true;
355
+ }
356
+
357
+ private handleNotificationAction(action: string) {
358
+ switch (action) {
359
+ case 'update_now':
360
+ this.performUpdate();
361
+ break;
362
+ case 'update_later':
363
+ this.scheduleReminder();
364
+ break;
365
+ case 'dismiss':
366
+ this.dismissUpdate();
367
+ break;
368
+ }
369
+ }
370
+
371
+ private async performUpdate() {
372
+ // Implement your update logic here
373
+ console.log('Performing update...');
374
+ }
375
+
376
+ private scheduleReminder() {
377
+ // Schedule a reminder for later
378
+ console.log('Scheduling reminder...');
379
+ }
380
+
381
+ private dismissUpdate() {
382
+ // Handle dismissal
383
+ console.log('Update dismissed');
384
+ }
385
+ }
386
+
387
+ // Usage
388
+ const updateManager = new BackgroundUpdateManager();
389
+ await updateManager.initialize();
390
+ ```
391
+
392
+ This comprehensive background update feature provides a robust solution for keeping your app updated automatically while providing excellent user experience through native notifications and proper system integration.