cordova-plugin-hot-updates 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/LICENSE +193 -0
- package/README.md +487 -0
- package/package.json +65 -0
- package/plugin.xml +83 -0
- package/scripts/afterInstall.js +25 -0
- package/scripts/beforeInstall.js +14 -0
- package/src/ios/HotUpdates.h +182 -0
- package/src/ios/HotUpdates.m +836 -0
- package/www/HotUpdates.js +192 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
CUSTOM NON-COMMERCIAL LICENSE
|
|
2
|
+
Version 1.0, 2025
|
|
3
|
+
|
|
4
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
5
|
+
|
|
6
|
+
1. Definitions.
|
|
7
|
+
|
|
8
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
9
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
14
|
+
other entities that control, are controlled by, or are under common
|
|
15
|
+
control with that entity. For the purposes of this definition,
|
|
16
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
17
|
+
direction or management of such entity, whether by contract or
|
|
18
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
19
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
20
|
+
|
|
21
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
22
|
+
exercising permissions granted by this License.
|
|
23
|
+
|
|
24
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
25
|
+
including but not limited to software source code, documentation
|
|
26
|
+
source, and configuration files.
|
|
27
|
+
|
|
28
|
+
"Object" form shall mean any form resulting from mechanical
|
|
29
|
+
transformation or translation of a Source form, including but
|
|
30
|
+
not limited to compiled object code, generated documentation,
|
|
31
|
+
and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
34
|
+
Object form, made available under the License, as indicated by a
|
|
35
|
+
copyright notice that is included in or attached to the work
|
|
36
|
+
(which shall not include communications that are expressly excluded
|
|
37
|
+
from License by an express written agreement by the copyright owner).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based upon (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and derivative works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean any work of authorship, including
|
|
48
|
+
the original version of the Work and any modifications or additions
|
|
49
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
50
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
51
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
52
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
53
|
+
means any form of electronic, verbal, or written communication sent
|
|
54
|
+
to the Licensor or its representatives, including but not limited to
|
|
55
|
+
communication on electronic mailing lists, source code control
|
|
56
|
+
systems, and issue tracking systems that are managed by, or on behalf
|
|
57
|
+
of, the Licensor for the purpose of discussing and improving the Work,
|
|
58
|
+
but excluding communication that is conspicuously marked or otherwise
|
|
59
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
60
|
+
|
|
61
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
62
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
63
|
+
subsequently incorporated within the Work.
|
|
64
|
+
|
|
65
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
66
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
67
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
68
|
+
copyright license to use, reproduce, modify, distribute, and otherwise
|
|
69
|
+
create derivative works from the contents of the Work, EXCLUSIVELY FOR
|
|
70
|
+
NON-COMMERCIAL PURPOSES ONLY.
|
|
71
|
+
|
|
72
|
+
COMMERCIAL USE IS STRICTLY PROHIBITED without explicit written
|
|
73
|
+
permission from the copyright holder. Commercial use includes, but is
|
|
74
|
+
not limited to: selling, licensing for profit, using in commercial
|
|
75
|
+
products or services, or any use that generates revenue.
|
|
76
|
+
|
|
77
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
78
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
79
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
80
|
+
(except as stated in this section) patent license to make, have made,
|
|
81
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
82
|
+
where such license applies only to those patent claims licensable
|
|
83
|
+
by such Contributor that are necessarily infringed by their
|
|
84
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
85
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
86
|
+
institute patent litigation against any entity (including a
|
|
87
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
88
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
89
|
+
or contributory patent infringement, then any patent licenses
|
|
90
|
+
granted to You under this License for that Work shall terminate
|
|
91
|
+
as of the date such litigation is filed.
|
|
92
|
+
|
|
93
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
94
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
95
|
+
modifications, and in Source or Object form, provided that You
|
|
96
|
+
meet the following conditions:
|
|
97
|
+
|
|
98
|
+
(a) You must give any other recipients of the Work or
|
|
99
|
+
Derivative Works a copy of this License; and
|
|
100
|
+
|
|
101
|
+
(b) You must cause any modified files to carry prominent notices
|
|
102
|
+
stating that You changed the files; and
|
|
103
|
+
|
|
104
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
105
|
+
that You distribute, all copyright, trademark, patent,
|
|
106
|
+
attribution and other notices from the Source form of the Work,
|
|
107
|
+
excluding those notices that do not pertain to any part of
|
|
108
|
+
the Derivative Works; and
|
|
109
|
+
|
|
110
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
111
|
+
distribution, then any Derivative Works that You distribute must
|
|
112
|
+
include a readable copy of the attribution notices contained
|
|
113
|
+
within such NOTICE file, excluding those notices that do not
|
|
114
|
+
pertain to any part of the Derivative Works, in at least one
|
|
115
|
+
of the following places: within a NOTICE text file distributed
|
|
116
|
+
as part of the Derivative Works; within the Source form or
|
|
117
|
+
documentation, if provided along with the Derivative Works; or,
|
|
118
|
+
within a display generated by the Derivative Works, if and
|
|
119
|
+
wherever such third-party notices normally appear. The contents
|
|
120
|
+
of the NOTICE file are for informational purposes only and
|
|
121
|
+
do not modify the License. You may add Your own attribution
|
|
122
|
+
notices within Derivative Works that You distribute, alongside
|
|
123
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
124
|
+
that such additional attribution notices cannot be construed
|
|
125
|
+
as modifying the License.
|
|
126
|
+
|
|
127
|
+
You may add Your own copyright notice to Your modifications and
|
|
128
|
+
may provide additional or different license terms and conditions
|
|
129
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
130
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
131
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
132
|
+
the conditions stated in this License.
|
|
133
|
+
|
|
134
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
135
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
136
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
137
|
+
this License, without any additional terms or conditions.
|
|
138
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
139
|
+
the terms of any separate license agreement you may have executed
|
|
140
|
+
with Licensor regarding such Contributions.
|
|
141
|
+
|
|
142
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
143
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
144
|
+
except as required for reasonable and customary use in describing the
|
|
145
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
146
|
+
|
|
147
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
148
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
149
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
150
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
151
|
+
implied, including, without limitation, any warranties or conditions
|
|
152
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
153
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
154
|
+
appropriateness of using or redistributing the Work and assume any
|
|
155
|
+
risks associated with Your exercise of permissions under this License.
|
|
156
|
+
|
|
157
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
158
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
159
|
+
unless required by applicable law (such as deliberate and grossly
|
|
160
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
161
|
+
liable to You for damages, including any direct, indirect, special,
|
|
162
|
+
incidental, or consequential damages of any character arising as a
|
|
163
|
+
result of this License or out of the use or inability to use the
|
|
164
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
165
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
166
|
+
other commercial damages or losses), even if such Contributor
|
|
167
|
+
has been advised of the possibility of such damages.
|
|
168
|
+
|
|
169
|
+
9. Accepting Warranty or Additional Liability. When redistributing
|
|
170
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
171
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
172
|
+
or other liability obligations and/or rights consistent with this
|
|
173
|
+
License. However, in accepting such obligations, You may act only
|
|
174
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
175
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
176
|
+
defend, and hold each Contributor harmless for any liability
|
|
177
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
178
|
+
of your accepting any such warranty or additional liability.
|
|
179
|
+
|
|
180
|
+
END OF TERMS AND CONDITIONS
|
|
181
|
+
|
|
182
|
+
Copyright 2025 Mustafin Vladimir
|
|
183
|
+
|
|
184
|
+
This software is licensed under the Custom Non-Commercial License.
|
|
185
|
+
You may use, modify, and distribute this software for NON-COMMERCIAL
|
|
186
|
+
purposes only. Any commercial use is strictly prohibited without
|
|
187
|
+
explicit written permission from the copyright holder.
|
|
188
|
+
|
|
189
|
+
For commercial licensing inquiries, please contact: Mustafin Vladimir
|
|
190
|
+
|
|
191
|
+
Unless required by applicable law or agreed to in writing, software
|
|
192
|
+
distributed under this License is provided on an "AS IS" BASIS,
|
|
193
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
package/README.md
ADDED
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
# Cordova Hot Updates Plugin
|
|
2
|
+
|
|
3
|
+
🔥 **Automatic over-the-air (OTA) hot updates for Cordova applications using WebView Reload approach**
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/cordova-plugin-hot-updates)
|
|
6
|
+
[](#license)
|
|
7
|
+
|
|
8
|
+
This plugin enables seamless web content updates for your Cordova iOS applications without requiring App Store approval. Updates are downloaded in the background and applied automatically on the next app launch.
|
|
9
|
+
|
|
10
|
+
## 🚀 Key Features
|
|
11
|
+
|
|
12
|
+
- **🔄 Automatic Background Updates**: Continuously checks for and downloads updates
|
|
13
|
+
- **⚡ Instant Application**: WebView Reload approach for immediate effect
|
|
14
|
+
- **📦 Semantic Versioning**: Smart version comparison and compatibility checks
|
|
15
|
+
- **🛡️ Rollback Support**: Automatic fallback on corrupted updates
|
|
16
|
+
- **⚙️ Configurable**: Customizable server URLs and check intervals
|
|
17
|
+
- **🎯 Zero Configuration**: Works out of the box with sensible defaults
|
|
18
|
+
|
|
19
|
+
## 📋 Table of Contents
|
|
20
|
+
|
|
21
|
+
- [Installation](#-installation)
|
|
22
|
+
- [Quick Start](#-quick-start)
|
|
23
|
+
- [Configuration](#-configuration)
|
|
24
|
+
- [API Reference](#-api-reference)
|
|
25
|
+
- [Server Implementation](#-server-implementation)
|
|
26
|
+
- [How It Works](#-how-it-works)
|
|
27
|
+
- [Troubleshooting](#-troubleshooting)
|
|
28
|
+
- [Contributing](#-contributing)
|
|
29
|
+
- [License](#-license)
|
|
30
|
+
|
|
31
|
+
## 📦 Installation
|
|
32
|
+
|
|
33
|
+
### Standard Installation (Recommended)
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Install from npm registry
|
|
37
|
+
cordova plugin add cordova-plugin-hot-updates
|
|
38
|
+
|
|
39
|
+
# Install CocoaPods dependencies (iOS)
|
|
40
|
+
cd platforms/ios
|
|
41
|
+
pod install
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Alternative Installation Methods
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Install from GitHub
|
|
48
|
+
cordova plugin add https://github.com/vladimirDarksy/Cordova_hot_update.git
|
|
49
|
+
|
|
50
|
+
# Install from local path
|
|
51
|
+
cordova plugin add /path/to/cordova-plugin-hot-updates
|
|
52
|
+
|
|
53
|
+
# Install specific version
|
|
54
|
+
cordova plugin add cordova-plugin-hot-updates@1.0.0
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Installation with pnpm
|
|
58
|
+
|
|
59
|
+
If your project uses pnpm, you may need additional configuration:
|
|
60
|
+
|
|
61
|
+
1. Create or update `.npmrc` in your project root:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
public-hoist-pattern[]=cordova-plugin-*
|
|
65
|
+
shamefully-hoist=true
|
|
66
|
+
auto-install-peers=true
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
2. Then install the plugin:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cordova plugin add cordova-plugin-hot-updates
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Note**: Cordova CLI internally uses npm, which can sometimes conflict with pnpm's node_modules structure. The above configuration helps resolve this.
|
|
76
|
+
|
|
77
|
+
## 🚀 Quick Start
|
|
78
|
+
|
|
79
|
+
### 1. Configure Your Server URL
|
|
80
|
+
|
|
81
|
+
Add to your `config.xml`:
|
|
82
|
+
|
|
83
|
+
```xml
|
|
84
|
+
<preference name="hot_updates_server_url" value="https://your-server.com/api/updates" />
|
|
85
|
+
<preference name="hot_updates_check_interval" value="300000" />
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 2. Basic Usage
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
// Check current version
|
|
92
|
+
HotUpdates.getCurrentVersion(
|
|
93
|
+
function(version) {
|
|
94
|
+
console.log('Current version:', version);
|
|
95
|
+
},
|
|
96
|
+
function(error) {
|
|
97
|
+
console.error('Error:', error);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
// Check for pending updates
|
|
102
|
+
HotUpdates.getPendingUpdateInfo(
|
|
103
|
+
function(info) {
|
|
104
|
+
if (info.hasPendingUpdate) {
|
|
105
|
+
console.log('Update ready:', info.pendingVersion);
|
|
106
|
+
alert('New update will be applied on next app restart');
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
function(error) {
|
|
110
|
+
console.error('Error:', error);
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
// Manually check for updates
|
|
115
|
+
HotUpdates.checkForUpdates(
|
|
116
|
+
function(result) {
|
|
117
|
+
if (result.hasUpdate) {
|
|
118
|
+
console.log('Update available:', result.availableVersion);
|
|
119
|
+
// Optionally download manually
|
|
120
|
+
HotUpdates.downloadUpdate(
|
|
121
|
+
result.downloadURL,
|
|
122
|
+
result.availableVersion,
|
|
123
|
+
function() {
|
|
124
|
+
console.log('Download completed');
|
|
125
|
+
},
|
|
126
|
+
function(error) {
|
|
127
|
+
console.error('Download failed:', error);
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
function(error) {
|
|
133
|
+
console.error('Check failed:', error);
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## ⚙️ Configuration
|
|
139
|
+
|
|
140
|
+
### config.xml Preferences
|
|
141
|
+
|
|
142
|
+
| Preference | Default | Description |
|
|
143
|
+
|------------|---------|-------------|
|
|
144
|
+
| `hot_updates_server_url` | `https://your-server.com/api/updates` | Update server endpoint |
|
|
145
|
+
| `hot_updates_check_interval` | `300000` | Check interval in milliseconds (5 minutes) |
|
|
146
|
+
| `hot_updates_auto_download` | `true` | Enable automatic download |
|
|
147
|
+
| `hot_updates_auto_install` | `true` | Enable automatic installation on restart |
|
|
148
|
+
|
|
149
|
+
### Example Configuration
|
|
150
|
+
|
|
151
|
+
```xml
|
|
152
|
+
<widget id="com.yourcompany.yourapp" version="1.0.0">
|
|
153
|
+
<!-- Hot Updates Configuration -->
|
|
154
|
+
<preference name="hot_updates_server_url" value="https://updates.yourapp.com/api/check" />
|
|
155
|
+
<preference name="hot_updates_check_interval" value="600000" />
|
|
156
|
+
<preference name="hot_updates_auto_download" value="true" />
|
|
157
|
+
<preference name="hot_updates_auto_install" value="true" />
|
|
158
|
+
|
|
159
|
+
<!-- Your other configurations... -->
|
|
160
|
+
</widget>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## 📚 API Reference
|
|
164
|
+
|
|
165
|
+
### Methods
|
|
166
|
+
|
|
167
|
+
#### `getCurrentVersion(successCallback, errorCallback)`
|
|
168
|
+
|
|
169
|
+
Gets the currently active version string.
|
|
170
|
+
|
|
171
|
+
```javascript
|
|
172
|
+
HotUpdates.getCurrentVersion(
|
|
173
|
+
function(version) {
|
|
174
|
+
console.log('Current version:', version); // "1.2.3"
|
|
175
|
+
},
|
|
176
|
+
function(error) {
|
|
177
|
+
console.error('Error getting version:', error);
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### `getPendingUpdateInfo(successCallback, errorCallback)`
|
|
183
|
+
|
|
184
|
+
Gets information about downloaded updates waiting to be installed.
|
|
185
|
+
|
|
186
|
+
```javascript
|
|
187
|
+
HotUpdates.getPendingUpdateInfo(
|
|
188
|
+
function(info) {
|
|
189
|
+
// info object contains:
|
|
190
|
+
// - hasPendingUpdate: boolean
|
|
191
|
+
// - pendingVersion: string
|
|
192
|
+
// - appBundleVersion: string
|
|
193
|
+
// - installedVersion: string
|
|
194
|
+
// - message: string
|
|
195
|
+
},
|
|
196
|
+
function(error) {
|
|
197
|
+
console.error('Error getting update info:', error);
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
#### `checkForUpdates(successCallback, errorCallback)`
|
|
203
|
+
|
|
204
|
+
Manually triggers an update check.
|
|
205
|
+
|
|
206
|
+
```javascript
|
|
207
|
+
HotUpdates.checkForUpdates(
|
|
208
|
+
function(result) {
|
|
209
|
+
// result object contains:
|
|
210
|
+
// - hasUpdate: boolean
|
|
211
|
+
// - currentVersion: string
|
|
212
|
+
// - availableVersion: string (if hasUpdate is true)
|
|
213
|
+
// - downloadURL: string (if hasUpdate is true)
|
|
214
|
+
// - minAppVersion: string (if specified)
|
|
215
|
+
},
|
|
216
|
+
function(error) {
|
|
217
|
+
console.error('Update check failed:', error);
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
#### `downloadUpdate(downloadURL, version, successCallback, errorCallback, progressCallback)`
|
|
223
|
+
|
|
224
|
+
Manually downloads a specific update.
|
|
225
|
+
|
|
226
|
+
```javascript
|
|
227
|
+
HotUpdates.downloadUpdate(
|
|
228
|
+
'https://server.com/updates/v2.0.0.zip',
|
|
229
|
+
'2.0.0',
|
|
230
|
+
function() {
|
|
231
|
+
console.log('Download completed');
|
|
232
|
+
},
|
|
233
|
+
function(error) {
|
|
234
|
+
console.error('Download failed:', error);
|
|
235
|
+
},
|
|
236
|
+
function(progress) {
|
|
237
|
+
console.log('Download progress:', progress + '%');
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
#### `getConfiguration(successCallback, errorCallback)`
|
|
243
|
+
|
|
244
|
+
Gets the current plugin configuration.
|
|
245
|
+
|
|
246
|
+
```javascript
|
|
247
|
+
HotUpdates.getConfiguration(
|
|
248
|
+
function(config) {
|
|
249
|
+
// config object contains:
|
|
250
|
+
// - serverURL: string
|
|
251
|
+
// - checkInterval: number (milliseconds)
|
|
252
|
+
// - appBundleVersion: string
|
|
253
|
+
// - autoDownload: boolean
|
|
254
|
+
},
|
|
255
|
+
function(error) {
|
|
256
|
+
console.error('Error getting config:', error);
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## 🖥️ Server Implementation
|
|
262
|
+
|
|
263
|
+
Your update server should implement the following API:
|
|
264
|
+
|
|
265
|
+
### Check for Updates Endpoint
|
|
266
|
+
|
|
267
|
+
**GET** `/check?version={currentVersion}&platform=ios`
|
|
268
|
+
|
|
269
|
+
**Response** (when update available):
|
|
270
|
+
```json
|
|
271
|
+
{
|
|
272
|
+
"hasUpdate": true,
|
|
273
|
+
"version": "1.2.0",
|
|
274
|
+
"downloadURL": "https://yourserver.com/updates/v1.2.0.zip",
|
|
275
|
+
"minAppVersion": "1.0.0",
|
|
276
|
+
"releaseNotes": "Bug fixes and improvements"
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**Response** (when no update available):
|
|
281
|
+
```json
|
|
282
|
+
{
|
|
283
|
+
"hasUpdate": false,
|
|
284
|
+
"message": "No updates available"
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Update Package Format
|
|
289
|
+
|
|
290
|
+
Your update ZIP file should contain a `www` folder with your web content:
|
|
291
|
+
|
|
292
|
+
```
|
|
293
|
+
update.zip
|
|
294
|
+
└── www/
|
|
295
|
+
├── index.html
|
|
296
|
+
├── js/
|
|
297
|
+
├── css/
|
|
298
|
+
├── img/
|
|
299
|
+
└── ...
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Example Server Implementation (Node.js)
|
|
303
|
+
|
|
304
|
+
```javascript
|
|
305
|
+
const express = require('express');
|
|
306
|
+
const app = express();
|
|
307
|
+
|
|
308
|
+
app.get('/api/updates/check', (req, res) => {
|
|
309
|
+
const { version, platform } = req.query;
|
|
310
|
+
const currentVersion = version || '1.0.0';
|
|
311
|
+
const latestVersion = '1.2.0'; // Your latest version
|
|
312
|
+
|
|
313
|
+
if (compareVersions(currentVersion, latestVersion) < 0) {
|
|
314
|
+
res.json({
|
|
315
|
+
hasUpdate: true,
|
|
316
|
+
version: latestVersion,
|
|
317
|
+
downloadURL: `https://yourserver.com/updates/v${latestVersion}.zip`,
|
|
318
|
+
minAppVersion: '1.0.0',
|
|
319
|
+
releaseNotes: 'Bug fixes and improvements'
|
|
320
|
+
});
|
|
321
|
+
} else {
|
|
322
|
+
res.json({
|
|
323
|
+
hasUpdate: false,
|
|
324
|
+
message: 'No updates available'
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
function compareVersions(version1, version2) {
|
|
330
|
+
const v1parts = version1.split('.').map(Number);
|
|
331
|
+
const v2parts = version2.split('.').map(Number);
|
|
332
|
+
|
|
333
|
+
for (let i = 0; i < Math.max(v1parts.length, v2parts.length); i++) {
|
|
334
|
+
const v1part = v1parts[i] || 0;
|
|
335
|
+
const v2part = v2parts[i] || 0;
|
|
336
|
+
|
|
337
|
+
if (v1part < v2part) return -1;
|
|
338
|
+
if (v1part > v2part) return 1;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
return 0;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
app.listen(3000, () => {
|
|
345
|
+
console.log('Update server running on port 3000');
|
|
346
|
+
});
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## 🔧 How It Works
|
|
350
|
+
|
|
351
|
+
### WebView Reload Approach
|
|
352
|
+
|
|
353
|
+
1. **Startup Check**: On app launch, the plugin checks for pending updates
|
|
354
|
+
2. **Installation**: If found, updates are installed to `Documents/www`
|
|
355
|
+
3. **WebView Switch**: The WebView is configured to load from `Documents/www` instead of bundle
|
|
356
|
+
4. **Background Process**: Automatic checking and downloading runs in background
|
|
357
|
+
5. **Next Launch**: New updates are applied on next app restart
|
|
358
|
+
|
|
359
|
+
### File Structure
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
Documents/
|
|
363
|
+
├── www/ # Updated web content (active)
|
|
364
|
+
├── pending_update/ # Downloaded update waiting for installation
|
|
365
|
+
│ └── www/ # New web content
|
|
366
|
+
└── www_backup/ # Backup of previous version (for rollback)
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Update Lifecycle
|
|
370
|
+
|
|
371
|
+
```
|
|
372
|
+
[Bundle] -> [Check] -> [Download] -> [Prepare] -> [Install] -> [Reload]
|
|
373
|
+
↑ ↓
|
|
374
|
+
└─────────────────── [Next App Launch] ←──────────────────────┘
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
## 🐛 Troubleshooting
|
|
378
|
+
|
|
379
|
+
### Common Issues
|
|
380
|
+
|
|
381
|
+
**Plugin installation fails or plugin not found**
|
|
382
|
+
- **npm registry**: Ensure plugin is published to npm
|
|
383
|
+
- **pnpm users**: Add hoisting configuration to `.npmrc` (see Installation with pnpm section)
|
|
384
|
+
- **Git installation**: Use full GitHub URL: `cordova plugin add https://github.com/vladimirDarksy/Cordova_hot_update.git`
|
|
385
|
+
- **Verify installation**: Run `cordova plugin list` to check if plugin is installed
|
|
386
|
+
|
|
387
|
+
**pnpm + Cordova compatibility issues**
|
|
388
|
+
If you're using pnpm and Cordova can't find the plugin:
|
|
389
|
+
|
|
390
|
+
1. Add to your project's `.npmrc`:
|
|
391
|
+
```
|
|
392
|
+
public-hoist-pattern[]=cordova-plugin-*
|
|
393
|
+
shamefully-hoist=true
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
2. Remove and reinstall:
|
|
397
|
+
```bash
|
|
398
|
+
cordova plugin remove cordova-plugin-hot-updates
|
|
399
|
+
rm -rf node_modules
|
|
400
|
+
pnpm install
|
|
401
|
+
cordova plugin add cordova-plugin-hot-updates
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
3. If still not working, check that Cordova CLI can access the plugin:
|
|
405
|
+
```bash
|
|
406
|
+
ls node_modules/cordova-plugin-hot-updates
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**Updates not downloading**
|
|
410
|
+
- Check your server URL in config.xml
|
|
411
|
+
- Verify server is returning correct JSON format
|
|
412
|
+
- Check device network connectivity
|
|
413
|
+
- Enable debugging with `cordova run ios --device --debug`
|
|
414
|
+
|
|
415
|
+
**WebView not reloading updated content**
|
|
416
|
+
- Ensure `Documents/www/index.html` exists
|
|
417
|
+
- Check iOS device logs for WebView errors
|
|
418
|
+
- Verify ZIP package contains `www` folder
|
|
419
|
+
|
|
420
|
+
**CocoaPods issues**
|
|
421
|
+
- Run `pod install` in `platforms/ios` directory
|
|
422
|
+
- Update CocoaPods: `sudo gem install cocoapods`
|
|
423
|
+
- Clean and rebuild: `cordova clean ios && cordova build ios`
|
|
424
|
+
|
|
425
|
+
### Debug Logging
|
|
426
|
+
|
|
427
|
+
The plugin provides extensive console logging. To view:
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
# iOS Simulator
|
|
431
|
+
cordova run ios --debug
|
|
432
|
+
|
|
433
|
+
# iOS Device
|
|
434
|
+
# Use Xcode console or Safari Web Inspector
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### Reset Plugin State
|
|
438
|
+
|
|
439
|
+
```javascript
|
|
440
|
+
// Clear all plugin data (for testing)
|
|
441
|
+
localStorage.removeItem('hot_updates_installed_version');
|
|
442
|
+
localStorage.removeItem('hot_updates_pending_version');
|
|
443
|
+
localStorage.removeItem('hot_updates_has_pending');
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
## ⚠️ Important Notes
|
|
447
|
+
|
|
448
|
+
- **iOS Only**: Currently supports iOS platform only
|
|
449
|
+
- **HTTPS Required**: Update server should use HTTPS in production
|
|
450
|
+
- **App Store Compliance**: Only update web content, not native code
|
|
451
|
+
- **Testing**: Test thoroughly on real devices before production
|
|
452
|
+
- **Rollback**: Keep ability to rollback via App Store if needed
|
|
453
|
+
|
|
454
|
+
## 📄 Requirements
|
|
455
|
+
|
|
456
|
+
- **Cordova**: >= 7.0.0
|
|
457
|
+
- **cordova-ios**: >= 4.4.0
|
|
458
|
+
- **iOS**: >= 11.0
|
|
459
|
+
- **CocoaPods**: For SSZipArchive dependency
|
|
460
|
+
|
|
461
|
+
## 🤝 Contributing
|
|
462
|
+
|
|
463
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
464
|
+
|
|
465
|
+
1. Fork the repository
|
|
466
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
467
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
468
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
469
|
+
5. Open a Pull Request
|
|
470
|
+
|
|
471
|
+
## 📝 License
|
|
472
|
+
|
|
473
|
+
This project is licensed under the Custom Non-Commercial License - see the [LICENSE](LICENSE) file for details.
|
|
474
|
+
|
|
475
|
+
**⚠️ Commercial use is strictly prohibited without explicit written permission from the copyright holder.**
|
|
476
|
+
|
|
477
|
+
For commercial licensing inquiries, please contact: **Mustafin Vladimir**
|
|
478
|
+
|
|
479
|
+
## 🙋♂️ Support
|
|
480
|
+
|
|
481
|
+
- **Issues**: [GitHub Issues](https://github.com/vladimirDarksy/Cordova_hot_update/issues)
|
|
482
|
+
- **Documentation**: This README and inline code documentation
|
|
483
|
+
- **Discussions**: [GitHub Discussions](https://github.com/vladimirDarksy/Cordova_hot_update/discussions)
|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
**Made with ❤️ by [Mustafin Vladimir](https://github.com/vladimirDarksy)**
|