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,18 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'CapacitorNativeUpdate'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '13.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.9'
17
+ s.frameworks = 'LocalAuthentication', 'Security'
18
+ end
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Ahsan Mahmood
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/Readme.md ADDED
@@ -0,0 +1,451 @@
1
+ # Capacitor Native Update Plugin
2
+
3
+ > ⚠️ **IMPORTANT: Production-Ready with Complete Examples** ⚠️
4
+ >
5
+ > This package is now **feature-complete** with significant improvements:
6
+ >
7
+ > - ✅ **Production Backend Example Included** - Full server implementation in `production-backend/`
8
+ > - ✅ **Complete Example App** - React + Firebase Functions in `example-app/`
9
+ > - ✅ **Native Implementations Complete** - iOS (Swift) and Android (Kotlin) fully implemented
10
+ > - ✅ **Comprehensive Test Suite** - Unit and integration tests with Vitest
11
+ > - ✅ **Development Tools Included** - Bundle creator, signer, and CLI tools
12
+ > - ✅ **Security Features Implemented** - HTTPS enforcement, signatures, checksums
13
+ >
14
+ > **🚀 Try the complete example app in `example-app/` to see all features in action!**
15
+
16
+ ## 📚 Documentation
17
+
18
+ ### Getting Started
19
+
20
+ - **[Installation Guide](./docs/getting-started/installation.md)** - Step-by-step installation instructions
21
+ - **[Quick Start Guide](./docs/getting-started/quick-start.md)** - Get up and running in minutes
22
+ - **[Configuration Guide](./docs/getting-started/configuration.md)** - Detailed configuration options
23
+
24
+ ### Features Documentation
25
+
26
+ - **[Live Updates (OTA)](./docs/features/live-updates.md)** - Deploy web updates instantly
27
+ - **[App Updates](./docs/features/app-updates.md)** - Native app store update management
28
+ - **[App Reviews](./docs/features/app-reviews.md)** - In-app review integration
29
+ - **[Background Updates](./docs/background-updates.md)** - Background update management
30
+
31
+ ### Guides & Best Practices
32
+
33
+ - **[Security Best Practices](./docs/guides/security-best-practices.md)** - Implement secure updates
34
+ - **[Migration Guide](./docs/MIGRATION.md)** - Migrate from other solutions
35
+ - **[Production Readiness](./docs/production-readiness.md)** - Production deployment checklist
36
+ - **[Bundle Signing](./docs/BUNDLE_SIGNING.md)** - Cryptographic signing guide
37
+
38
+ ### API Reference
39
+
40
+ - **[Live Update API](./docs/api/live-update-api.md)** - Complete API for OTA updates
41
+ - **[App Update API](./docs/api/app-update-api.md)** - Native app update methods
42
+ - **[App Review API](./docs/api/app-review-api.md)** - Review request methods
43
+ - **[Events API](./docs/api/events-api.md)** - Event listeners and handlers
44
+
45
+ ### Examples
46
+
47
+ - **[Basic Usage](./docs/examples/basic-usage.md)** - Simple implementation examples
48
+ - **[Advanced Scenarios](./docs/examples/advanced-scenarios.md)** - Complex use cases
49
+
50
+ ---
51
+
52
+ A **foundation package** for building a comprehensive update management plugin for Capacitor that combines Live/OTA updates, native app store updates, and in-app review capabilities. This package provides the architecture, interfaces, and documentation but requires additional implementation work.
53
+
54
+ ## Features
55
+
56
+ ### 🚀 Live Updates (OTA)
57
+
58
+ Deploy JavaScript, HTML, and CSS updates instantly without going through app store approval:
59
+
60
+ - **Multiple update strategies**: Immediate, background, or manual updates
61
+ - **Delta updates**: Only download changed files for faster updates
62
+ - **Automatic rollback**: Revert to previous version if update fails
63
+ - **Update channels**: Support for production, staging, and development environments
64
+ - **Security**: End-to-end encryption and signature verification
65
+
66
+ ### 📱 Native App Updates
67
+
68
+ Seamlessly manage app store updates with native UI integration:
69
+
70
+ - **Version checking**: Detect when newer versions are available
71
+ - **Flexible updates**: Background download with user-controlled installation
72
+ - **Immediate updates**: Force critical updates with blocking UI
73
+ - **Platform integration**: Google Play Core (Android) and App Store (iOS) support
74
+
75
+ ### ⭐ App Reviews
76
+
77
+ Increase user engagement with intelligent review prompts:
78
+
79
+ - **In-app reviews**: Native review dialogs without leaving the app
80
+ - **Smart triggering**: Request reviews at optimal moments
81
+ - **Rate limiting**: Respect platform limits (iOS: 3x/year)
82
+ - **Analytics**: Track review request performance
83
+
84
+ ## Installation
85
+
86
+ ```bash
87
+ npm install native-update
88
+ npx cap sync
89
+ ```
90
+
91
+ ## Quick Start
92
+
93
+ ### 1. Basic Setup
94
+
95
+ ```typescript
96
+ import { CapacitorNativeUpdate } from 'native-update';
97
+
98
+ // Initialize on app start
99
+ async function initializeApp() {
100
+ // Configure the plugin
101
+ await CapacitorNativeUpdate.configure({
102
+ updateUrl: 'https://updates.yourdomain.com/api/v1',
103
+ autoCheck: true,
104
+ publicKey: 'your-public-key-for-security',
105
+ });
106
+ }
107
+ ```
108
+
109
+ ### 2. Live Updates (OTA)
110
+
111
+ ```typescript
112
+ // Check and apply live updates
113
+ async function checkLiveUpdates() {
114
+ try {
115
+ const { available, version } = await CapacitorNativeUpdate.checkForUpdate();
116
+
117
+ if (available) {
118
+ // Download update with progress
119
+ await CapacitorNativeUpdate.downloadUpdate({
120
+ onProgress: (progress) => {
121
+ console.log(`Downloading: ${progress.percent}%`);
122
+ },
123
+ });
124
+
125
+ // Apply update (app will restart)
126
+ await CapacitorNativeUpdate.applyUpdate();
127
+ }
128
+ } catch (error) {
129
+ console.error('Update failed:', error);
130
+ }
131
+ }
132
+ ```
133
+
134
+ ### 3. Native App Updates
135
+
136
+ ```typescript
137
+ // Check for app store updates
138
+ async function checkNativeUpdates() {
139
+ const result = await CapacitorNativeUpdate.checkAppUpdate();
140
+
141
+ if (result.updateAvailable) {
142
+ if (result.immediateUpdateAllowed) {
143
+ // Critical update - must install
144
+ await CapacitorNativeUpdate.startImmediateUpdate();
145
+ } else if (result.flexibleUpdateAllowed) {
146
+ // Optional update - download in background
147
+ await CapacitorNativeUpdate.startFlexibleUpdate();
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ ### 4. App Reviews
154
+
155
+ ```typescript
156
+ // Request app review at the right moment
157
+ async function requestAppReview() {
158
+ // Only ask after positive interactions
159
+ const shouldAsk = await checkIfGoodMoment();
160
+
161
+ if (shouldAsk) {
162
+ const result = await CapacitorNativeUpdate.requestReview();
163
+ if (result.displayed) {
164
+ console.log('Review prompt was shown');
165
+ }
166
+ }
167
+ }
168
+ ```
169
+
170
+ ## Real-World Example
171
+
172
+ ```typescript
173
+ import { Component, OnInit } from '@angular/core';
174
+ import { CapacitorNativeUpdate } from 'native-update';
175
+ import { AlertController } from '@ionic/angular';
176
+
177
+ @Component({
178
+ selector: 'app-root',
179
+ templateUrl: 'app.component.html',
180
+ })
181
+ export class AppComponent implements OnInit {
182
+ constructor(private alertCtrl: AlertController) {}
183
+
184
+ async ngOnInit() {
185
+ // Check for updates on app start
186
+ await this.checkAllUpdates();
187
+
188
+ // Set up periodic checks
189
+ setInterval(() => this.checkAllUpdates(), 3600000); // Every hour
190
+ }
191
+
192
+ async checkAllUpdates() {
193
+ // 1. Check live updates first (fastest)
194
+ const liveUpdate = await CapacitorNativeUpdate.checkForUpdate();
195
+ if (liveUpdate.available) {
196
+ await this.promptLiveUpdate(liveUpdate);
197
+ return; // Don't check native if live update is available
198
+ }
199
+
200
+ // 2. Check native updates
201
+ const nativeUpdate = await CapacitorNativeUpdate.checkAppUpdate();
202
+ if (nativeUpdate.updateAvailable) {
203
+ await this.promptNativeUpdate(nativeUpdate);
204
+ }
205
+ }
206
+
207
+ async promptLiveUpdate(update: any) {
208
+ const alert = await this.alertCtrl.create({
209
+ header: 'Update Available',
210
+ message: `Version ${update.version} is ready to install`,
211
+ buttons: [
212
+ { text: 'Later', role: 'cancel' },
213
+ {
214
+ text: 'Update',
215
+ handler: () => this.installLiveUpdate(),
216
+ },
217
+ ],
218
+ });
219
+ await alert.present();
220
+ }
221
+
222
+ async installLiveUpdate() {
223
+ // Download and apply
224
+ await CapacitorNativeUpdate.downloadUpdate();
225
+ await CapacitorNativeUpdate.applyUpdate(); // App restarts
226
+ }
227
+
228
+ // Request review after positive events
229
+ async onPositiveEvent() {
230
+ setTimeout(() => {
231
+ CapacitorNativeUpdate.requestReview();
232
+ }, 2000);
233
+ }
234
+ }
235
+ ```
236
+
237
+ ## Configuration
238
+
239
+ ### capacitor.config.json
240
+
241
+ ```json
242
+ {
243
+ "plugins": {
244
+ "CapacitorNativeUpdate": {
245
+ "updateUrl": "https://updates.yourdomain.com/api/v1",
246
+ "autoCheck": true,
247
+ "checkInterval": 3600,
248
+ "channel": "production",
249
+ "publicKey": "YOUR_BASE64_PUBLIC_KEY",
250
+ "appStoreId": "123456789",
251
+ "enforceMinVersion": true
252
+ }
253
+ }
254
+ }
255
+ ```
256
+
257
+ ## Platform Support
258
+
259
+ | Platform | Live Updates | App Updates | App Reviews |
260
+ | -------- | ------------ | ----------- | ----------- |
261
+ | iOS | ✅ | ✅ | ✅ |
262
+ | Android | ✅ | ✅ | ✅ |
263
+ | Web | ✅ | ⚠️ | ⚠️ |
264
+
265
+ ⚠️ = Graceful fallback with limited functionality
266
+
267
+ ## Requirements
268
+
269
+ - Capacitor 5.0+
270
+ - iOS 13.0+
271
+ - Android 5.0+ (API 21+)
272
+
273
+ ## Security
274
+
275
+ This plugin implements multiple security layers:
276
+
277
+ - **HTTPS enforcement** for all update downloads
278
+ - **Public key signature verification** for bundle integrity
279
+ - **Checksum validation** before applying updates
280
+ - **Certificate pinning** support for enhanced security
281
+
282
+ ## 🎯 Complete Example Implementation
283
+
284
+ ### Full-Featured Example App
285
+
286
+ The **[example-app](./example-app)** directory contains a complete, production-ready implementation:
287
+
288
+ #### Frontend (React + Capacitor)
289
+ - ✅ All plugin features demonstrated
290
+ - ✅ Live update management UI
291
+ - ✅ App store update integration
292
+ - ✅ In-app review prompts
293
+ - ✅ Security implementation
294
+ - ✅ Analytics dashboard
295
+ - ✅ Error handling & recovery
296
+
297
+ #### Backend (Firebase Functions)
298
+ - ✅ Complete update server
299
+ - ✅ Bundle management API
300
+ - ✅ Authentication & security
301
+ - ✅ Analytics collection
302
+ - ✅ Firestore + Storage integration
303
+ - ✅ Auto-scaling infrastructure
304
+
305
+ **🚀 Get started:** See [example-app/README.md](./example-app/README.md) for setup instructions.
306
+
307
+ ## Contributing
308
+
309
+ We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details.
310
+
311
+ ## 🛠️ New Development Tools
312
+
313
+ ### Available Tools
314
+
315
+ ✅ **Testing Framework**
316
+ - Vitest test setup with example tests
317
+ - Run tests: `npm test`
318
+ - Coverage: `npm run test:coverage`
319
+
320
+ ✅ **Bundle Creation Tool**
321
+ - Create update bundles: `node tools/bundle-creator.js create ./dist`
322
+ - Generates ZIP bundle with manifest
323
+
324
+ ✅ **Security Signing Tool**
325
+ - Generate keys: `node tools/bundle-signer.js generate-keys`
326
+ - Sign bundles: `node tools/bundle-signer.js sign bundle.zip private-key.pem`
327
+ - Verify: `node tools/bundle-signer.js verify bundle.zip bundle.zip.sig public-key.pem`
328
+
329
+ ✅ **Minimal Backend Server**
330
+ - Development server in `backend-template/`
331
+ - Start: `cd backend-template && npm install && npm start`
332
+ - Provides basic update API endpoints
333
+
334
+ ## 🏗️ Development Status
335
+
336
+ ### What This Package Provides
337
+
338
+ ✅ **Architecture & Design**
339
+ - Well-designed TypeScript interfaces and plugin structure
340
+ - Modular architecture for live updates, app updates, and reviews
341
+ - Security-first design patterns
342
+
343
+ ✅ **Documentation**
344
+ - Comprehensive API documentation
345
+ - Security best practices guide
346
+ - Implementation examples and guides
347
+
348
+ ✅ **Foundation Code**
349
+ - TypeScript/Web implementation
350
+ - Plugin interfaces and definitions
351
+ - Basic native platform stubs
352
+
353
+ ### What You Need to Build
354
+
355
+ ❌ **Backend Infrastructure**
356
+ - Update server with API endpoints
357
+ - Bundle storage and CDN
358
+ - Version management system
359
+ - Signing and encryption services
360
+
361
+ ❌ **Complete Native Implementation**
362
+ - Verify and complete iOS implementation
363
+ - Verify and complete Android implementation
364
+ - Platform-specific testing
365
+
366
+ ❌ **Testing & Quality Assurance**
367
+ - Unit tests for all modules
368
+ - Integration tests
369
+ - End-to-end testing
370
+ - Security testing
371
+
372
+ ❌ **Tooling & Utilities**
373
+ - Bundle creation tools
374
+ - Signing utilities
375
+ - Deployment scripts
376
+ - Monitoring solutions
377
+
378
+ ## 🚀 Getting Started with Development
379
+
380
+ 1. **Understand the Architecture**:
381
+ - Review the documentation in `/docs/`
382
+ - Study the TypeScript interfaces in `/src/definitions.ts`
383
+ - Check the [ROADMAP.md](./ROADMAP.md) for development priorities
384
+
385
+ 2. **Build Required Infrastructure**:
386
+ - Set up an update server (see [server requirements](./docs/server-requirements.md))
387
+ - Implement bundle storage solution
388
+ - Create signing infrastructure
389
+
390
+ 3. **Complete Native Implementation**:
391
+ - Test and verify iOS implementation
392
+ - Test and verify Android implementation
393
+ - Ensure all plugin methods work correctly
394
+
395
+ 4. **Create Testing Suite**:
396
+ - Add unit tests for TypeScript code
397
+ - Create integration tests for native platforms
398
+ - Implement end-to-end testing scenarios
399
+
400
+ ## 💡 Key Benefits
401
+
402
+ - **Zero Downtime Updates**: Deploy fixes instantly without app store delays
403
+ - **Native Integration**: Seamless platform-specific implementations
404
+ - **Developer Friendly**: Comprehensive TypeScript support and documentation
405
+ - **Community Driven**: Open-source with active community support
406
+ - **Professional Support**: Enterprise support options available
407
+
408
+ ## 🤝 Community & Support
409
+
410
+ This package is **open-source** and created by **Ahsan Mahmood** for the developer community. We welcome contributions, feedback, and collaboration.
411
+
412
+ ### Community Resources
413
+
414
+ - **[GitHub Repository](https://github.com/aoneahsan/native-update)** - Source code and issues
415
+ - **[Documentation](./docs/README.md)** - Comprehensive documentation
416
+ - **[Examples](./docs/examples/)** - Real-world usage examples
417
+ - **[Contributing Guide](./CONTRIBUTING.md)** - How to contribute
418
+
419
+ ### Professional Support
420
+
421
+ - **Custom Implementation**: Tailored solutions for your needs
422
+ - **Security Audits**: Professional security assessments
423
+ - **Performance Optimization**: Performance tuning and optimization
424
+ - **Training and Consulting**: Team training and consultation
425
+
426
+ ## 📈 Why Use This Foundation?
427
+
428
+ - **Solid Architecture**: Well-designed plugin structure and interfaces
429
+ - **Platform Agnostic**: Works with any JavaScript framework
430
+ - **Security-First**: Built with security best practices in mind
431
+ - **Comprehensive Documentation**: Detailed guides for implementation
432
+
433
+ ## License
434
+
435
+ MIT License - see [LICENSE](./LICENSE) for details.
436
+
437
+ ## Support
438
+
439
+ - 📧 Email: aoneahsan@gmail.com
440
+ - 🌐 Website: [Ahsan Mahmood](https://aoneahsan.com)
441
+ - 💼 LinkedIn: [Ahsan Mahmood](https://linkedin.com/in/aoneahsan)
442
+ - 🐛 Issues: [GitHub Issues](https://github.com/aoneahsan/native-update/issues)
443
+
444
+ ## Author
445
+
446
+ **Ahsan Mahmood**
447
+
448
+ - Portfolio: [aoneahsan.com](https://aoneahsan.com)
449
+ - GitHub: [aoneahsan](https://github.com/aoneahsan)
450
+ - Email: aoneahsan@gmail.com
451
+ - Phone: +923046619706
@@ -0,0 +1,92 @@
1
+ ext {
2
+ compileSdkVersion = 34
3
+ targetSdkVersion = 34
4
+ minSdkVersion = 21
5
+ androidxAppCompatVersion = '1.6.1'
6
+ androidxCoreVersion = '1.13.1'
7
+ androidxWorkVersion = '2.9.0'
8
+ playServicesVersion = '18.2.0'
9
+ playReviewVersion = '2.0.1'
10
+ okhttpVersion = '4.12.0'
11
+ kotlinVersion = '2.0.21'
12
+ }
13
+
14
+ buildscript {
15
+ repositories {
16
+ google()
17
+ mavenCentral()
18
+ }
19
+ dependencies {
20
+ classpath 'com.android.tools.build:gradle:8.7.2'
21
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
22
+ }
23
+ }
24
+
25
+ apply plugin: 'com.android.library'
26
+ apply plugin: 'kotlin-android'
27
+
28
+ android {
29
+ namespace "com.aoneahsan.nativeupdate"
30
+ compileSdkVersion project.compileSdkVersion
31
+
32
+ defaultConfig {
33
+ minSdkVersion project.minSdkVersion
34
+ targetSdkVersion project.targetSdkVersion
35
+ versionCode 1
36
+ versionName "1.0"
37
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
38
+ }
39
+
40
+ buildTypes {
41
+ release {
42
+ minifyEnabled false
43
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
44
+ }
45
+ }
46
+
47
+ lint {
48
+ abortOnError false
49
+ }
50
+
51
+ compileOptions {
52
+ sourceCompatibility JavaVersion.VERSION_17
53
+ targetCompatibility JavaVersion.VERSION_17
54
+ }
55
+
56
+ kotlinOptions {
57
+ jvmTarget = '17'
58
+ }
59
+ }
60
+
61
+ repositories {
62
+ google()
63
+ mavenCentral()
64
+ }
65
+
66
+ dependencies {
67
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
68
+ implementation project(':capacitor-android')
69
+
70
+ // AndroidX
71
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
72
+ implementation "androidx.core:core-ktx:$androidxCoreVersion"
73
+ implementation "androidx.work:work-runtime-ktx:$androidxWorkVersion"
74
+
75
+ // Google Play Services
76
+ implementation "com.google.android.play:app-update:$playServicesVersion"
77
+ implementation "com.google.android.play:app-update-ktx:$playServicesVersion"
78
+ implementation "com.google.android.play:review:$playReviewVersion"
79
+ implementation "com.google.android.play:review-ktx:$playReviewVersion"
80
+
81
+ // OkHttp for secure network requests
82
+ implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
83
+ implementation "com.squareup.okhttp3:okhttp-tls:$okhttpVersion"
84
+
85
+ // Security
86
+ implementation 'androidx.security:security-crypto:1.1.0-alpha06'
87
+
88
+ // Testing
89
+ testImplementation 'junit:junit:4.13.2'
90
+ androidTestImplementation 'androidx.test.ext:junit:1.1.5'
91
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
92
+ }
@@ -0,0 +1,8 @@
1
+ # Gradle Wrapper Properties
2
+ distributionBase=GRADLE_USER_HOME
3
+ distributionPath=wrapper/dists
4
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
5
+ networkTimeout=10000
6
+ validateDistributionUrl=true
7
+ zipStoreBase=GRADLE_USER_HOME
8
+ zipStorePath=wrapper/dists
@@ -0,0 +1,17 @@
1
+ # Project-wide Gradle settings.
2
+
3
+ # IDE (e.g. Android Studio) users:
4
+ # Gradle settings configured through the IDE *will override*
5
+ # any settings specified in this file.
6
+
7
+ # For more details on how to configure your build environment visit
8
+ # http://www.gradle.org/docs/current/userguide/build_environment.html
9
+
10
+ # Enable AndroidX
11
+ android.useAndroidX=true
12
+
13
+ # Automatically convert third-party libraries to use AndroidX
14
+ android.enableJetifier=true
15
+
16
+ # Kotlin code style
17
+ kotlin.code.style=official
@@ -0,0 +1,29 @@
1
+ # Add project specific ProGuard rules here.
2
+ # You can control the set of applied configuration files using the
3
+ # proguardFiles setting in build.gradle.
4
+ #
5
+ # For more details, see
6
+ # http://developer.android.com/guide/developing/tools/proguard.html
7
+
8
+ # Uncomment this to preserve the line number information for
9
+ # debugging stack traces.
10
+ -keepattributes SourceFile,LineNumberTable
11
+
12
+ # If you keep the line number information, uncomment this to
13
+ # hide the original source file name.
14
+ #-renamesourcefileattribute SourceFile
15
+
16
+ # Capacitor Native Update Plugin
17
+ -keep class com.aoneahsan.nativeupdate.** { *; }
18
+
19
+ # OkHttp
20
+ -dontwarn okhttp3.**
21
+ -dontwarn okio.**
22
+ -dontwarn javax.annotation.**
23
+ -keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
24
+
25
+ # Google Play Services
26
+ -keep class com.google.android.play.** { *; }
27
+
28
+ # Security Crypto
29
+ -keep class androidx.security.crypto.** { *; }
@@ -0,0 +1,2 @@
1
+ include ':native-update'
2
+ project(':native-update').projectDir = new File('../.')
@@ -0,0 +1,34 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.aoneahsan.nativeupdate">
3
+
4
+ <!-- Required permissions -->
5
+ <uses-permission android:name="android.permission.INTERNET" />
6
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7
+
8
+ <!-- Optional permissions (requested at runtime) -->
9
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
10
+ android:maxSdkVersion="28" />
11
+
12
+ <!-- Background update permissions -->
13
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
14
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
15
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
16
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
17
+
18
+ <!-- WorkManager service -->
19
+ <service
20
+ android:name="androidx.work.impl.foreground.SystemForegroundService"
21
+ android:foregroundServiceType="dataSync" />
22
+
23
+ <!-- Broadcast receiver for notification actions -->
24
+ <receiver
25
+ android:name="com.aoneahsan.nativeupdate.NotificationActionReceiver"
26
+ android:exported="false">
27
+ <intent-filter>
28
+ <action android:name="com.aoneahsan.nativeupdate.UPDATE_NOW" />
29
+ <action android:name="com.aoneahsan.nativeupdate.UPDATE_LATER" />
30
+ <action android:name="com.aoneahsan.nativeupdate.DISMISS" />
31
+ </intent-filter>
32
+ </receiver>
33
+
34
+ </manifest>