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.
- package/CapacitorNativeUpdate.podspec +18 -0
- package/LICENSE +21 -0
- package/Readme.md +451 -0
- package/android/build.gradle +92 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/android/gradle.properties +17 -0
- package/android/proguard-rules.pro +29 -0
- package/android/settings.gradle +2 -0
- package/android/src/main/AndroidManifest.xml +34 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/AppReviewPlugin.kt +153 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/AppUpdatePlugin.kt +275 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundNotificationManager.kt +390 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateManager.kt +46 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdatePlugin.kt +333 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateWorker.kt +251 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/CapacitorNativeUpdatePlugin.kt +265 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +526 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/NotificationActionReceiver.kt +99 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/SecurityManager.kt +249 -0
- package/dist/esm/__tests__/bundle-manager.test.d.ts +1 -0
- package/dist/esm/__tests__/bundle-manager.test.js +123 -0
- package/dist/esm/__tests__/bundle-manager.test.js.map +1 -0
- package/dist/esm/__tests__/config.test.d.ts +1 -0
- package/dist/esm/__tests__/config.test.js +69 -0
- package/dist/esm/__tests__/config.test.js.map +1 -0
- package/dist/esm/__tests__/integration.test.d.ts +1 -0
- package/dist/esm/__tests__/integration.test.js +78 -0
- package/dist/esm/__tests__/integration.test.js.map +1 -0
- package/dist/esm/__tests__/security.test.d.ts +1 -0
- package/dist/esm/__tests__/security.test.js +54 -0
- package/dist/esm/__tests__/security.test.js.map +1 -0
- package/dist/esm/__tests__/version-manager.test.d.ts +1 -0
- package/dist/esm/__tests__/version-manager.test.js +45 -0
- package/dist/esm/__tests__/version-manager.test.js.map +1 -0
- package/dist/esm/app-review/app-review-manager.d.ts +24 -0
- package/dist/esm/app-review/app-review-manager.js +195 -0
- package/dist/esm/app-review/app-review-manager.js.map +1 -0
- package/dist/esm/app-review/index.d.ts +5 -0
- package/dist/esm/app-review/index.js +6 -0
- package/dist/esm/app-review/index.js.map +1 -0
- package/dist/esm/app-review/platform-review-handler.d.ts +20 -0
- package/dist/esm/app-review/platform-review-handler.js +138 -0
- package/dist/esm/app-review/platform-review-handler.js.map +1 -0
- package/dist/esm/app-review/review-conditions-checker.d.ts +22 -0
- package/dist/esm/app-review/review-conditions-checker.js +155 -0
- package/dist/esm/app-review/review-conditions-checker.js.map +1 -0
- package/dist/esm/app-review/review-rate-limiter.d.ts +23 -0
- package/dist/esm/app-review/review-rate-limiter.js +164 -0
- package/dist/esm/app-review/review-rate-limiter.js.map +1 -0
- package/dist/esm/app-review/types.d.ts +41 -0
- package/dist/esm/app-review/types.js +2 -0
- package/dist/esm/app-review/types.js.map +1 -0
- package/dist/esm/app-update/app-update-checker.d.ts +13 -0
- package/dist/esm/app-update/app-update-checker.js +104 -0
- package/dist/esm/app-update/app-update-checker.js.map +1 -0
- package/dist/esm/app-update/app-update-installer.d.ts +19 -0
- package/dist/esm/app-update/app-update-installer.js +123 -0
- package/dist/esm/app-update/app-update-installer.js.map +1 -0
- package/dist/esm/app-update/app-update-manager.d.ts +28 -0
- package/dist/esm/app-update/app-update-manager.js +199 -0
- package/dist/esm/app-update/app-update-manager.js.map +1 -0
- package/dist/esm/app-update/app-update-notifier.d.ts +14 -0
- package/dist/esm/app-update/app-update-notifier.js +100 -0
- package/dist/esm/app-update/app-update-notifier.js.map +1 -0
- package/dist/esm/app-update/index.d.ts +6 -0
- package/dist/esm/app-update/index.js +7 -0
- package/dist/esm/app-update/index.js.map +1 -0
- package/dist/esm/app-update/platform-app-update.d.ts +19 -0
- package/dist/esm/app-update/platform-app-update.js +129 -0
- package/dist/esm/app-update/platform-app-update.js.map +1 -0
- package/dist/esm/app-update/types.d.ts +58 -0
- package/dist/esm/app-update/types.js +12 -0
- package/dist/esm/app-update/types.js.map +1 -0
- package/dist/esm/background-update/background-scheduler.d.ts +17 -0
- package/dist/esm/background-update/background-scheduler.js +195 -0
- package/dist/esm/background-update/background-scheduler.js.map +1 -0
- package/dist/esm/background-update/index.d.ts +3 -0
- package/dist/esm/background-update/index.js +3 -0
- package/dist/esm/background-update/index.js.map +1 -0
- package/dist/esm/background-update/notification-manager.d.ts +29 -0
- package/dist/esm/background-update/notification-manager.js +89 -0
- package/dist/esm/background-update/notification-manager.js.map +1 -0
- package/dist/esm/core/analytics.d.ts +70 -0
- package/dist/esm/core/analytics.js +137 -0
- package/dist/esm/core/analytics.js.map +1 -0
- package/dist/esm/core/cache-manager.d.ts +72 -0
- package/dist/esm/core/cache-manager.js +275 -0
- package/dist/esm/core/cache-manager.js.map +1 -0
- package/dist/esm/core/config.d.ts +48 -0
- package/dist/esm/core/config.js +83 -0
- package/dist/esm/core/config.js.map +1 -0
- package/dist/esm/core/errors.d.ts +51 -0
- package/dist/esm/core/errors.js +80 -0
- package/dist/esm/core/errors.js.map +1 -0
- package/dist/esm/core/logger.d.ts +21 -0
- package/dist/esm/core/logger.js +109 -0
- package/dist/esm/core/logger.js.map +1 -0
- package/dist/esm/core/performance.d.ts +53 -0
- package/dist/esm/core/performance.js +140 -0
- package/dist/esm/core/performance.js.map +1 -0
- package/dist/esm/core/plugin-manager.d.ts +66 -0
- package/dist/esm/core/plugin-manager.js +148 -0
- package/dist/esm/core/plugin-manager.js.map +1 -0
- package/dist/esm/core/security.d.ts +93 -0
- package/dist/esm/core/security.js +315 -0
- package/dist/esm/core/security.js.map +1 -0
- package/dist/esm/definitions.d.ts +639 -0
- package/dist/esm/definitions.js +103 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/live-update/bundle-manager.d.ts +94 -0
- package/dist/esm/live-update/bundle-manager.js +310 -0
- package/dist/esm/live-update/bundle-manager.js.map +1 -0
- package/dist/esm/live-update/certificate-pinning.d.ts +38 -0
- package/dist/esm/live-update/certificate-pinning.js +78 -0
- package/dist/esm/live-update/certificate-pinning.js.map +1 -0
- package/dist/esm/live-update/download-manager.d.ts +67 -0
- package/dist/esm/live-update/download-manager.js +319 -0
- package/dist/esm/live-update/download-manager.js.map +1 -0
- package/dist/esm/live-update/update-manager.d.ts +52 -0
- package/dist/esm/live-update/update-manager.js +294 -0
- package/dist/esm/live-update/update-manager.js.map +1 -0
- package/dist/esm/live-update/version-manager.d.ts +84 -0
- package/dist/esm/live-update/version-manager.js +335 -0
- package/dist/esm/live-update/version-manager.js.map +1 -0
- package/dist/esm/plugin.d.ts +6 -0
- package/dist/esm/plugin.js +283 -0
- package/dist/esm/plugin.js.map +1 -0
- package/dist/esm/security/crypto.d.ts +25 -0
- package/dist/esm/security/crypto.js +70 -0
- package/dist/esm/security/crypto.js.map +1 -0
- package/dist/esm/security/validator.d.ts +60 -0
- package/dist/esm/security/validator.js +143 -0
- package/dist/esm/security/validator.js.map +1 -0
- package/dist/esm/web.d.ts +74 -0
- package/dist/esm/web.js +595 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +2 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.esm.js +2 -0
- package/dist/plugin.esm.js.map +1 -0
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -0
- package/docs/APP_REVIEW_GUIDE.md +768 -0
- package/docs/BUNDLE_SIGNING.md +264 -0
- package/docs/LIVE_UPDATES_GUIDE.md +650 -0
- package/docs/MIGRATION.md +192 -0
- package/docs/NATIVE_UPDATES_GUIDE.md +694 -0
- package/docs/QUICK_START.md +606 -0
- package/docs/README.md +111 -0
- package/docs/REMAINING_FEATURES.md +139 -0
- package/docs/api/app-review-api.md +259 -0
- package/docs/api/app-update-api.md +238 -0
- package/docs/api/events-api.md +451 -0
- package/docs/api/live-update-api.md +265 -0
- package/docs/background-updates.md +392 -0
- package/docs/examples/advanced-scenarios.md +410 -0
- package/docs/examples/basic-usage.md +185 -0
- package/docs/features/app-reviews.md +975 -0
- package/docs/features/app-updates.md +785 -0
- package/docs/features/live-updates.md +633 -0
- package/docs/getting-started/configuration.md +468 -0
- package/docs/getting-started/installation.md +209 -0
- package/docs/getting-started/quick-start.md +379 -0
- package/docs/guides/deployment-guide.md +333 -0
- package/docs/guides/migration-from-codepush.md +142 -0
- package/docs/guides/security-best-practices.md +1057 -0
- package/docs/guides/testing-guide.md +373 -0
- package/docs/production-readiness.md +478 -0
- package/docs/security/certificate-pinning.md +122 -0
- package/docs/server-requirements.md +147 -0
- package/ios/Plugin/AppReview/AppReviewPlugin.swift +158 -0
- package/ios/Plugin/AppUpdate/AppUpdatePlugin.swift +234 -0
- package/ios/Plugin/BackgroundUpdate/BackgroundNotificationManager.swift +329 -0
- package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +396 -0
- package/ios/Plugin/CapacitorNativeUpdatePlugin.m +45 -0
- package/ios/Plugin/CapacitorNativeUpdatePlugin.swift +190 -0
- package/ios/Plugin/Info.plist +43 -0
- package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +689 -0
- package/ios/Plugin/LiveUpdate/WebViewConfiguration.swift +45 -0
- package/ios/Plugin/Security/SecurityManager.swift +289 -0
- 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,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>
|