@appzung/react-native-code-push 5.7.1 → 6.4.2
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/CONTRIBUTING.md +17 -19
- package/CodePush.js +11 -4
- package/CodePush.podspec +3 -3
- package/README.md +93 -37
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +44 -7
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +0 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +77 -22
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +14 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +15 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/TLSSocketFactory.java +72 -0
- package/android/codepush.gradle +1 -1
- package/docs/api-android.md +21 -3
- package/docs/api-js.md +3 -3
- package/docs/multi-deployment-testing-android.md +63 -22
- package/docs/multi-deployment-testing-ios.md +17 -11
- package/docs/setup-android.md +79 -19
- package/docs/setup-ios.md +57 -7
- package/docs/setup-windows.md +1 -1
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +0 -0
- package/ios/CodePush/CodePush.m +104 -24
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +0 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +0 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +0 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +0 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +0 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +0 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +0 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +0 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +0 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +0 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +0 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +0 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +0 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +0 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +0 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +0 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +0 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +0 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +0 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +0 -0
- package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +0 -0
- package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +0 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +0 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +0 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +0 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +0 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +0 -0
- package/ios/CodePush/SSZipArchive/Common.h +0 -0
- package/ios/CodePush/SSZipArchive/SSZipArchive.h +0 -0
- package/ios/CodePush/SSZipArchive/SSZipArchive.m +0 -0
- package/ios/CodePush/SSZipArchive/aes/aes.h +0 -0
- package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +0 -0
- package/ios/CodePush/SSZipArchive/aes/aescrypt.c +0 -0
- package/ios/CodePush/SSZipArchive/aes/aeskey.c +0 -0
- package/ios/CodePush/SSZipArchive/aes/aesopt.h +0 -0
- package/ios/CodePush/SSZipArchive/aes/aestab.c +0 -0
- package/ios/CodePush/SSZipArchive/aes/aestab.h +0 -0
- package/ios/CodePush/SSZipArchive/aes/brg_endian.h +0 -0
- package/ios/CodePush/SSZipArchive/aes/brg_types.h +0 -0
- package/ios/CodePush/SSZipArchive/aes/entropy.c +0 -0
- package/ios/CodePush/SSZipArchive/aes/entropy.h +0 -0
- package/ios/CodePush/SSZipArchive/aes/fileenc.c +0 -0
- package/ios/CodePush/SSZipArchive/aes/fileenc.h +0 -0
- package/ios/CodePush/SSZipArchive/aes/hmac.c +0 -0
- package/ios/CodePush/SSZipArchive/aes/hmac.h +0 -0
- package/ios/CodePush/SSZipArchive/aes/prng.c +0 -0
- package/ios/CodePush/SSZipArchive/aes/prng.h +0 -0
- package/ios/CodePush/SSZipArchive/aes/pwd2key.c +0 -0
- package/ios/CodePush/SSZipArchive/aes/pwd2key.h +0 -0
- package/ios/CodePush/SSZipArchive/aes/sha1.c +0 -0
- package/ios/CodePush/SSZipArchive/aes/sha1.h +0 -0
- package/ios/CodePush/SSZipArchive/minizip/crypt.h +0 -0
- package/ios/CodePush/SSZipArchive/minizip/ioapi.c +0 -0
- package/ios/CodePush/SSZipArchive/minizip/ioapi.h +0 -0
- package/ios/CodePush/SSZipArchive/minizip/mztools.c +0 -0
- package/ios/CodePush/SSZipArchive/minizip/mztools.h +0 -0
- package/ios/CodePush/SSZipArchive/minizip/unzip.c +0 -0
- package/ios/CodePush/SSZipArchive/minizip/unzip.h +0 -0
- package/ios/CodePush/SSZipArchive/minizip/zip.c +0 -0
- package/ios/CodePush/SSZipArchive/minizip/zip.h +0 -0
- package/package-mixins.js +2 -3
- package/package.json +36 -13
- package/react-native.config.js +10 -0
- package/request-fetch-adapter.js +1 -1
- package/scripts/generateBundledResourcesHash.js +1 -1
- package/scripts/postlink/android/postlink.js +2 -2
- package/scripts/postunlink/android/postunlink.js +3 -3
- package/scripts/tools/linkToolsAndroid.js +1 -1
- package/scripts/tools/linkToolsIos.js +2 -2
- package/tsconfig.json +14 -0
- package/tslint.json +32 -0
- package/typings/react-native-code-push.d.ts +14 -5
- package/RestartManager.js +0 -59
- package/gulpfile.js +0 -302
|
@@ -29,6 +29,7 @@ import org.json.JSONObject;
|
|
|
29
29
|
|
|
30
30
|
import java.io.IOException;
|
|
31
31
|
import java.lang.reflect.Field;
|
|
32
|
+
import java.util.ArrayList;
|
|
32
33
|
import java.util.Date;
|
|
33
34
|
import java.util.HashMap;
|
|
34
35
|
import java.util.List;
|
|
@@ -45,6 +46,10 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
45
46
|
private CodePushTelemetryManager mTelemetryManager;
|
|
46
47
|
private CodePushUpdateManager mUpdateManager;
|
|
47
48
|
|
|
49
|
+
private boolean _allowed = true;
|
|
50
|
+
private boolean _restartInProgress = false;
|
|
51
|
+
private ArrayList<Boolean> _restartQueue = new ArrayList<>();
|
|
52
|
+
|
|
48
53
|
public CodePushNativeModule(ReactApplicationContext reactContext, CodePush codePush, CodePushUpdateManager codePushUpdateManager, CodePushTelemetryManager codePushTelemetryManager, SettingsManager settingsManager) {
|
|
49
54
|
super(reactContext);
|
|
50
55
|
|
|
@@ -168,7 +173,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
168
173
|
|
|
169
174
|
// This workaround has been implemented in order to fix https://github.com/facebook/react-native/issues/14533
|
|
170
175
|
// resetReactRootViews allows to call recreateReactContextInBackground without any exceptions
|
|
171
|
-
// This fix also relates to https://github.com/
|
|
176
|
+
// This fix also relates to https://github.com/microsoft/react-native-code-push/issues/878
|
|
172
177
|
private void resetReactRootViews(ReactInstanceManager instanceManager) throws NoSuchFieldException, IllegalAccessException {
|
|
173
178
|
Field mAttachedRootViewsField = instanceManager.getClass().getDeclaredField("mAttachedRootViews");
|
|
174
179
|
mAttachedRootViewsField.setAccessible(true);
|
|
@@ -206,6 +211,74 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
206
211
|
return instanceManager;
|
|
207
212
|
}
|
|
208
213
|
|
|
214
|
+
private void restartAppInternal(boolean onlyIfUpdateIsPending) {
|
|
215
|
+
if (this._restartInProgress) {
|
|
216
|
+
CodePushUtils.log("Restart request queued until the current restart is completed");
|
|
217
|
+
this._restartQueue.add(onlyIfUpdateIsPending);
|
|
218
|
+
return;
|
|
219
|
+
} else if (!this._allowed) {
|
|
220
|
+
CodePushUtils.log("Restart request queued until restarts are re-allowed");
|
|
221
|
+
this._restartQueue.add(onlyIfUpdateIsPending);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
this._restartInProgress = true;
|
|
226
|
+
if (!onlyIfUpdateIsPending || mSettingsManager.isPendingUpdate(null)) {
|
|
227
|
+
loadBundle();
|
|
228
|
+
CodePushUtils.log("Restarting app");
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
this._restartInProgress = false;
|
|
233
|
+
if (this._restartQueue.size() > 0) {
|
|
234
|
+
boolean buf = this._restartQueue.get(0);
|
|
235
|
+
this._restartQueue.remove(0);
|
|
236
|
+
this.restartAppInternal(buf);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
@ReactMethod
|
|
241
|
+
public void allow(Promise promise) {
|
|
242
|
+
CodePushUtils.log("Re-allowing restarts");
|
|
243
|
+
this._allowed = true;
|
|
244
|
+
|
|
245
|
+
if (_restartQueue.size() > 0) {
|
|
246
|
+
CodePushUtils.log("Executing pending restart");
|
|
247
|
+
boolean buf = this._restartQueue.get(0);
|
|
248
|
+
this._restartQueue.remove(0);
|
|
249
|
+
this.restartAppInternal(buf);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
promise.resolve(null);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@ReactMethod
|
|
257
|
+
public void clearPendingRestart(Promise promise) {
|
|
258
|
+
this._restartQueue.clear();
|
|
259
|
+
promise.resolve(null);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
@ReactMethod
|
|
264
|
+
public void disallow(Promise promise) {
|
|
265
|
+
CodePushUtils.log("Disallowing restarts");
|
|
266
|
+
this._allowed = false;
|
|
267
|
+
promise.resolve(null);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
@ReactMethod
|
|
272
|
+
public void restartApp(boolean onlyIfUpdateIsPending, Promise promise) {
|
|
273
|
+
try {
|
|
274
|
+
restartAppInternal(onlyIfUpdateIsPending);
|
|
275
|
+
promise.resolve(null);
|
|
276
|
+
} catch(CodePushUnknownException e) {
|
|
277
|
+
CodePushUtils.log(e);
|
|
278
|
+
promise.reject(e);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
209
282
|
@ReactMethod
|
|
210
283
|
public void downloadUpdate(final ReadableMap updatePackage, final boolean notifyProgress, final Promise promise) {
|
|
211
284
|
AsyncTask<Void, Void, Void> asyncTask = new AsyncTask<Void, Void, Void>() {
|
|
@@ -411,7 +484,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
411
484
|
return null;
|
|
412
485
|
}
|
|
413
486
|
}
|
|
414
|
-
|
|
487
|
+
|
|
415
488
|
promise.resolve("");
|
|
416
489
|
} catch(CodePushUnknownException e) {
|
|
417
490
|
CodePushUtils.log(e);
|
|
@@ -460,7 +533,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
460
533
|
@Override
|
|
461
534
|
public void run() {
|
|
462
535
|
CodePushUtils.log("Loading bundle on suspend");
|
|
463
|
-
|
|
536
|
+
restartAppInternal(false);
|
|
464
537
|
}
|
|
465
538
|
};
|
|
466
539
|
|
|
@@ -474,7 +547,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
474
547
|
if (installMode == CodePushInstallMode.IMMEDIATE.getValue()
|
|
475
548
|
|| durationInBackground >= CodePushNativeModule.this.mMinimumBackgroundDuration) {
|
|
476
549
|
CodePushUtils.log("Loading bundle on resume");
|
|
477
|
-
|
|
550
|
+
restartAppInternal(false);
|
|
478
551
|
}
|
|
479
552
|
}
|
|
480
553
|
}
|
|
@@ -582,24 +655,6 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
582
655
|
}
|
|
583
656
|
}
|
|
584
657
|
|
|
585
|
-
@ReactMethod
|
|
586
|
-
public void restartApp(boolean onlyIfUpdateIsPending, Promise promise) {
|
|
587
|
-
try {
|
|
588
|
-
// If this is an unconditional restart request, or there
|
|
589
|
-
// is current pending update, then reload the app.
|
|
590
|
-
if (!onlyIfUpdateIsPending || mSettingsManager.isPendingUpdate(null)) {
|
|
591
|
-
loadBundle();
|
|
592
|
-
promise.resolve(true);
|
|
593
|
-
return;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
promise.resolve(false);
|
|
597
|
-
} catch(CodePushUnknownException e) {
|
|
598
|
-
CodePushUtils.log(e);
|
|
599
|
-
promise.reject(e);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
|
|
603
658
|
@ReactMethod
|
|
604
659
|
public void saveStatusReportForRetry(ReadableMap statusReport) {
|
|
605
660
|
try {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package com.microsoft.codepush.react;
|
|
2
2
|
|
|
3
|
+
import android.os.Build;
|
|
4
|
+
|
|
3
5
|
import org.json.JSONObject;
|
|
4
6
|
|
|
5
7
|
import java.io.BufferedInputStream;
|
|
@@ -12,6 +14,8 @@ import java.net.MalformedURLException;
|
|
|
12
14
|
import java.net.URL;
|
|
13
15
|
import java.nio.ByteBuffer;
|
|
14
16
|
|
|
17
|
+
import javax.net.ssl.HttpsURLConnection;
|
|
18
|
+
|
|
15
19
|
public class CodePushUpdateManager {
|
|
16
20
|
|
|
17
21
|
private String mDocumentsDirectory;
|
|
@@ -163,6 +167,16 @@ public class CodePushUpdateManager {
|
|
|
163
167
|
try {
|
|
164
168
|
URL downloadUrl = new URL(downloadUrlString);
|
|
165
169
|
connection = (HttpURLConnection) (downloadUrl.openConnection());
|
|
170
|
+
|
|
171
|
+
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP &&
|
|
172
|
+
downloadUrl.toString().startsWith("https")) {
|
|
173
|
+
try {
|
|
174
|
+
((HttpsURLConnection)connection).setSSLSocketFactory(new TLSSocketFactory());
|
|
175
|
+
} catch (Exception e) {
|
|
176
|
+
throw new CodePushUnknownException("Error set SSLSocketFactory. ", e);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
166
180
|
connection.setRequestProperty("Accept-Encoding", "identity");
|
|
167
181
|
bin = new BufferedInputStream(connection.getInputStream());
|
|
168
182
|
|
|
@@ -123,6 +123,20 @@ public class FileUtils {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
private static String validateFileName(String fileName, String targetDirectory) throws IOException {
|
|
127
|
+
File file = new File(fileName);
|
|
128
|
+
String canonicalPath = file.getCanonicalPath();
|
|
129
|
+
|
|
130
|
+
File targetFile = new File(targetDirectory);
|
|
131
|
+
String targetCanonicalPath = targetFile.getCanonicalPath();
|
|
132
|
+
|
|
133
|
+
if (!canonicalPath.startsWith(targetCanonicalPath)) {
|
|
134
|
+
throw new IllegalStateException("File is outside extraction target directory.");
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return canonicalPath;
|
|
138
|
+
}
|
|
139
|
+
|
|
126
140
|
public static void unzipFile(File zipFile, String destination) throws IOException {
|
|
127
141
|
FileInputStream fileStream = null;
|
|
128
142
|
BufferedInputStream bufferedStream = null;
|
|
@@ -142,7 +156,7 @@ public class FileUtils {
|
|
|
142
156
|
|
|
143
157
|
byte[] buffer = new byte[WRITE_BUFFER_SIZE];
|
|
144
158
|
while ((entry = zipStream.getNextEntry()) != null) {
|
|
145
|
-
String fileName = entry.getName();
|
|
159
|
+
String fileName = validateFileName(entry.getName(), ".");
|
|
146
160
|
File file = new File(destinationFolder, fileName);
|
|
147
161
|
if (entry.isDirectory()) {
|
|
148
162
|
file.mkdirs();
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
package com.microsoft.codepush.react;
|
|
2
|
+
|
|
3
|
+
import java.io.IOException;
|
|
4
|
+
import java.net.InetAddress;
|
|
5
|
+
import java.net.Socket;
|
|
6
|
+
import java.net.UnknownHostException;
|
|
7
|
+
import java.security.KeyManagementException;
|
|
8
|
+
import java.security.NoSuchAlgorithmException;
|
|
9
|
+
|
|
10
|
+
import javax.net.ssl.SSLContext;
|
|
11
|
+
import javax.net.ssl.SSLSocket;
|
|
12
|
+
import javax.net.ssl.SSLSocketFactory;
|
|
13
|
+
|
|
14
|
+
public class TLSSocketFactory extends SSLSocketFactory {
|
|
15
|
+
|
|
16
|
+
private SSLSocketFactory delegate;
|
|
17
|
+
|
|
18
|
+
public TLSSocketFactory() throws KeyManagementException, NoSuchAlgorithmException {
|
|
19
|
+
SSLContext context = SSLContext.getInstance("TLS");
|
|
20
|
+
context.init(null, null, null);
|
|
21
|
+
delegate = context.getSocketFactory();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Override
|
|
25
|
+
public String[] getDefaultCipherSuites() {
|
|
26
|
+
return delegate.getDefaultCipherSuites();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Override
|
|
30
|
+
public String[] getSupportedCipherSuites() {
|
|
31
|
+
return delegate.getSupportedCipherSuites();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Override
|
|
35
|
+
public Socket createSocket() throws IOException {
|
|
36
|
+
return enableTLSOnSocket(delegate.createSocket());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException {
|
|
41
|
+
return enableTLSOnSocket(delegate.createSocket(s, host, port, autoClose));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Override
|
|
45
|
+
public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
|
|
46
|
+
return enableTLSOnSocket(delegate.createSocket(host, port));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Override
|
|
50
|
+
public Socket createSocket(String host, int port, InetAddress localHost, int localPort)
|
|
51
|
+
throws IOException, UnknownHostException {
|
|
52
|
+
return enableTLSOnSocket(delegate.createSocket(host, port, localHost, localPort));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Override
|
|
56
|
+
public Socket createSocket(InetAddress host, int port) throws IOException {
|
|
57
|
+
return enableTLSOnSocket(delegate.createSocket(host, port));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@Override
|
|
61
|
+
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
|
|
62
|
+
throws IOException {
|
|
63
|
+
return enableTLSOnSocket(delegate.createSocket(address, port, localAddress, localPort));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private Socket enableTLSOnSocket(Socket socket) {
|
|
67
|
+
if (socket != null && (socket instanceof SSLSocket)) {
|
|
68
|
+
((SSLSocket) socket).setEnabledProtocols(new String[] { "TLSv1.1", "TLSv1.2" });
|
|
69
|
+
}
|
|
70
|
+
return socket;
|
|
71
|
+
}
|
|
72
|
+
}
|
package/android/codepush.gradle
CHANGED
|
@@ -20,7 +20,7 @@ void runBefore(String dependentTaskName, Task task) {
|
|
|
20
20
|
gradle.projectsEvaluated {
|
|
21
21
|
android.buildTypes.each {
|
|
22
22
|
// to prevent incorrect long value restoration from strings.xml we need to wrap it with double quotes
|
|
23
|
-
// https://github.com/
|
|
23
|
+
// https://github.com/microsoft/cordova-plugin-code-push/issues/264
|
|
24
24
|
it.resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
|
|
25
25
|
}
|
|
26
26
|
|
package/docs/api-android.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
### Java API Reference (Android)
|
|
2
2
|
|
|
3
|
+
### API for React Native 0.60 version and above
|
|
4
|
+
|
|
5
|
+
Since `autolinking` uses `react-native.config.js` to link plugins, constructors are specified in that file. But you can override custom variables to manage the CodePush plugin by placing these values in string resources.
|
|
6
|
+
|
|
7
|
+
* __Public Key__ - used for bundle verification in the Code Signing Feature. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more details about the Code Signing Feature.
|
|
8
|
+
To set the public key, you should add the content of the public key to `strings.xml` with name `CodePushPublicKey`. CodePush automatically gets this property and enables the Code Signing feature. For example:
|
|
9
|
+
```xml
|
|
10
|
+
<string moduleConfig="true" name="CodePushPublicKey">your-public-key</string>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
* __Server Url__ - used for specifying CodePush Server Url.
|
|
14
|
+
The Default value: "https://codepush.appzung.com/" is overridden by adding your path to `strings.xml` with name `CodePushServerUrl`. CodePush automatically gets this property and will use this path to send requests. For example:
|
|
15
|
+
```xml
|
|
16
|
+
<string moduleConfig="true" name="CodePushServerUrl">https://yourcodepush.server.com</string>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### API for React Native lower than 0.60
|
|
20
|
+
|
|
3
21
|
The Java API is made available by importing the `com.microsoft.codepush.react.CodePush` class into your `MainActivity.java` file, and consists of a single public class named `CodePush`.
|
|
4
22
|
|
|
5
23
|
#### CodePush
|
|
@@ -16,9 +34,9 @@ Constructs the CodePush client runtime and represents the `ReactPackage` instanc
|
|
|
16
34
|
|
|
17
35
|
2. The local cache that the React Native runtime maintains in debug mode is deleted whenever a CodePush update is installed. This ensures that when the app is restarted after an update is applied, you will see the expected changes. As soon as [this PR](https://github.com/facebook/react-native/pull/4738) is merged, we won't need to do this anymore.
|
|
18
36
|
|
|
19
|
-
- __CodePush(String deploymentKey, Context context, boolean isDebugMode, Integer publicKeyResourceDescriptor)__ - Equivalent to the previous constructor, but allows you to specify the public key resource descriptor needed to read public key content. Please refer to [Code Signing](setup-android.md#code-signing) section for more details about Code Signing Feature.
|
|
37
|
+
- __CodePush(String deploymentKey, Context context, boolean isDebugMode, Integer publicKeyResourceDescriptor)__ - Equivalent to the previous constructor, but allows you to specify the public key resource descriptor needed to read public key content. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more details about the Code Signing Feature.
|
|
20
38
|
|
|
21
|
-
- __CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl)__ Constructor allows you to specify CodePush Server Url. The Default value: `"https://codepush.appzung.com/"` is overridden by value
|
|
39
|
+
- __CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl)__ Constructor allows you to specify CodePush Server Url. The Default value: `"https://codepush.appzung.com/"` is overridden by value specified in `serverUrl`.
|
|
22
40
|
|
|
23
41
|
##### Builder
|
|
24
42
|
|
|
@@ -46,7 +64,7 @@ As an alternative to constructors *you can also use `CodePushBuilder`* to setup
|
|
|
46
64
|
|
|
47
65
|
* __public CodePushBuilder setServerUrl(String serverUrl)__ - allows you to specify CodePush Server Url. Default value: `"https://codepush.appzung.com/"`.
|
|
48
66
|
|
|
49
|
-
* __public CodePushBuilder setPublicKeyResourceDescriptor(int publicKeyResourceDescriptor)__ - allows you to specify Public Key resource descriptor which will be used for reading Public Key content for `strings.xml` file. Please refer to [Code Signing](#code-signing) section for more detailed information about purpose of this parameter.
|
|
67
|
+
* __public CodePushBuilder setPublicKeyResourceDescriptor(int publicKeyResourceDescriptor)__ - allows you to specify Public Key resource descriptor which will be used for reading Public Key content for `strings.xml` file. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more detailed information about purpose of this parameter.
|
|
50
68
|
|
|
51
69
|
* __public CodePush build()__ - return configured `CodePush` instance.
|
|
52
70
|
|
package/docs/api-js.md
CHANGED
|
@@ -60,10 +60,10 @@ This decorator provides support for letting you customize its behaviour to easil
|
|
|
60
60
|
export default MyApp;
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
2. **Silent sync
|
|
63
|
+
2. **Silent sync every time the app resumes**. Same as 1, except we check for updates, or apply an update if one exists every time the app returns to the foreground after being "backgrounded".
|
|
64
64
|
|
|
65
65
|
```javascript
|
|
66
|
-
// Sync for updates
|
|
66
|
+
// Sync for updates every time the app resumes.
|
|
67
67
|
class MyApp extends Component<{}> {}
|
|
68
68
|
MyApp = codePush({ checkFrequency: codePush.CheckFrequency.ON_APP_RESUME, installMode: codePush.InstallMode.ON_NEXT_RESUME })(MyApp);
|
|
69
69
|
export default MyApp;
|
|
@@ -128,7 +128,7 @@ The `codePush` decorator accepts an "options" object that allows you to customiz
|
|
|
128
128
|
|
|
129
129
|
* __minimumBackgroundDuration__ *(Number)* - Specifies the minimum number of seconds that the app needs to have been in the background before restarting the app. This property only applies to updates which are installed using `InstallMode.ON_NEXT_RESUME` or `InstallMode.ON_NEXT_SUSPEND`, and can be useful for getting your update in front of end users sooner, without being too obtrusive. Defaults to `0`, which has the effect of applying the update immediately after a resume or unless the app suspension is long enough to not matter, regardless how long it was in the background.
|
|
130
130
|
|
|
131
|
-
* __updateDialog__ *(UpdateDialogOptions)* - An "options" object used to determine whether a confirmation dialog should be displayed to the end user when an update is available, and if so, what strings to use. Defaults to `null`, which has the effect of disabling the dialog completely. Setting this to any truthy value will enable the dialog with the default strings, and passing an object to this parameter allows enabling the dialog as well as overriding one or more of the default strings. Before enabling this option within an App Store-distributed app, please refer to [this note](https://github.com/
|
|
131
|
+
* __updateDialog__ *(UpdateDialogOptions)* - An "options" object used to determine whether a confirmation dialog should be displayed to the end user when an update is available, and if so, what strings to use. Defaults to `null`, which has the effect of disabling the dialog completely. Setting this to any truthy value will enable the dialog with the default strings, and passing an object to this parameter allows enabling the dialog as well as overriding one or more of the default strings. Before enabling this option within an App Store-distributed app, please refer to [this note](https://github.com/microsoft/react-native-code-push#user-content-apple-note).
|
|
132
132
|
|
|
133
133
|
The following list represents the available options and their defaults:
|
|
134
134
|
|
|
@@ -2,15 +2,73 @@
|
|
|
2
2
|
|
|
3
3
|
> NOTE
|
|
4
4
|
>
|
|
5
|
-
> Complete demo configured with "multi-deployment testing" feature is [here](https://github.com/
|
|
5
|
+
> Complete demo configured with "multi-deployment testing" feature is [here](https://github.com/microsoft/react-native-code-push/files/1314118/rncp1004.zip).
|
|
6
6
|
|
|
7
|
-
The [Android Gradle plugin](
|
|
7
|
+
The [Android Gradle plugin](https://google.github.io/android-gradle-dsl/current/index.html) allows you to define custom config settings for each "build type" (like debug, release). This mechanism allows you to easily configure your debug builds to use your CodePush staging deployment key and your release builds to use your CodePush production deployment key.
|
|
8
|
+
|
|
9
|
+
*NOTE: As a reminder, you can retrieve these keys by running `appcenter codepush deployment list -a <ownerName>/<appName> -k` from your terminal.*
|
|
8
10
|
|
|
9
11
|
To set this up, perform the following steps:
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
**For React Native >= v0.60**
|
|
14
|
+
|
|
15
|
+
1. Open the project's app level `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects)
|
|
16
|
+
|
|
17
|
+
2. Find the `android { buildTypes {} }` section and define `resValue` entries for both your `debug` and `release` build types, which reference your `Staging` and `Production` deployment keys respectively.
|
|
18
|
+
|
|
19
|
+
```groovy
|
|
20
|
+
android {
|
|
21
|
+
...
|
|
22
|
+
buildTypes {
|
|
23
|
+
debug {
|
|
24
|
+
...
|
|
25
|
+
// Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
|
|
26
|
+
resValue "string", "CodePushDeploymentKey", '""'
|
|
27
|
+
...
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
releaseStaging {
|
|
31
|
+
...
|
|
32
|
+
resValue "string", "CodePushDeploymentKey", '"<INSERT_STAGING_KEY>"'
|
|
33
|
+
|
|
34
|
+
// Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues
|
|
35
|
+
// Add the following line if not already there
|
|
36
|
+
matchingFallbacks = ['release']
|
|
37
|
+
...
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
release {
|
|
41
|
+
...
|
|
42
|
+
resValue "string", "CodePushDeploymentKey", '"<INSERT_PRODUCTION_KEY>"'
|
|
43
|
+
...
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
...
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
*NOTE: Remember to remove the key from `strings.xml` if you are configuring the deployment key in the build process*
|
|
51
|
+
|
|
52
|
+
*NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).*
|
|
53
|
+
|
|
54
|
+
**For React Native v0.29 - v0.59**
|
|
55
|
+
|
|
56
|
+
1. Open up your `MainApplication.java` file and make the following changes:
|
|
57
|
+
|
|
58
|
+
```java
|
|
59
|
+
@Override
|
|
60
|
+
protected List<ReactPackage> getPackages() {
|
|
61
|
+
return Arrays.<ReactPackage>asList(
|
|
62
|
+
...
|
|
63
|
+
new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG), // Add/change this line.
|
|
64
|
+
...
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
12
68
|
|
|
13
|
-
2.
|
|
69
|
+
2. Open your app's `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects)
|
|
70
|
+
|
|
71
|
+
3. Find the `android { buildTypes {} }` section and define `buildConfigField` entries for both your `debug` and `release` build types, which reference your `Staging` and `Production` deployment keys respectively. If you prefer, you can define the key literals in your `gradle.properties` file, and then reference them here. Either way will work, and it's just a matter of personal preference.
|
|
14
72
|
|
|
15
73
|
```groovy
|
|
16
74
|
android {
|
|
@@ -42,27 +100,10 @@ To set this up, perform the following steps:
|
|
|
42
100
|
}
|
|
43
101
|
```
|
|
44
102
|
|
|
45
|
-
*NOTE: As a reminder, you can retrieve these keys by running `code-push deployment ls <APP_NAME> -k` from your terminal.*
|
|
46
|
-
|
|
47
103
|
*NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).*
|
|
48
104
|
|
|
49
105
|
4. Pass the deployment key to the `CodePush` constructor via the build config you defined, as opposed to a string literal.
|
|
50
106
|
|
|
51
|
-
**For React Native >= v0.29**
|
|
52
|
-
|
|
53
|
-
Open up your `MainApplication.java` file and make the following changes:
|
|
54
|
-
|
|
55
|
-
```java
|
|
56
|
-
@Override
|
|
57
|
-
protected List<ReactPackage> getPackages() {
|
|
58
|
-
return Arrays.<ReactPackage>asList(
|
|
59
|
-
...
|
|
60
|
-
new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG), // Add/change this line.
|
|
61
|
-
...
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
107
|
**For React Native v0.19 - v0.28**
|
|
67
108
|
|
|
68
109
|
Open up your `MainActivity.java` file and make the following changes:
|
|
@@ -104,4 +145,4 @@ buildTypes {
|
|
|
104
145
|
|
|
105
146
|
5. Optionally, create "mirrored" directories in the `app/src/debug/res` directory for all of your app's icons that you want to change for your debug build. This part isn't technically critical, but it can make it easier to quickly spot your debug builds on a device if its icon is noticeable different.
|
|
106
147
|
|
|
107
|
-
And that's it! View [here](http://tools.android.com/tech-docs/new-build-system/resource-merging) for more details on how resource merging works in Android.
|
|
148
|
+
And that's it! View [here](http://tools.android.com/tech-docs/new-build-system/resource-merging) for more details on how resource merging works in Android.
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
> NOTE
|
|
4
4
|
>
|
|
5
5
|
> Complete demos configured with "multi-deployment testing" feature are [here]:
|
|
6
|
-
> * **without using cocoa pods**: [link](https://github.com/
|
|
7
|
-
> * **using cocoa pods**: [link](https://github.com/
|
|
6
|
+
> * **without using cocoa pods**: [link](https://github.com/microsoft/react-native-code-push/files/1259957/rncp976.copy.zip)
|
|
7
|
+
> * **using cocoa pods**: [link](https://github.com/microsoft/react-native-code-push/files/1172217/rncp893.copy.zip)
|
|
8
8
|
|
|
9
9
|
Xcode allows you to define custom build settings for each "configuration" (like debug, release), which can then be referenced as the value of keys within the `Info.plist` file (like the `CodePushDeploymentKey` setting). This mechanism allows you to easily configure your builds to produce binaries, which are configured to synchronize with different CodePush deployments.
|
|
10
10
|
|
|
@@ -24,23 +24,29 @@ To set this up, perform the following steps:
|
|
|
24
24
|
|
|
25
25
|
6. Select the `Build Settings` tab
|
|
26
26
|
|
|
27
|
-
7.
|
|
27
|
+
7. Click the `+` button on the toolbar and select `Add User-Defined Setting`
|
|
28
28
|
|
|
29
|
-

|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Name this new setting something like `Multi_Deployment_Config`. Go to the setting and add value `$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)` for Release. After that add value `$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)` for Staging
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+

|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
*NOTE: For Xcode 10 and lower version: Go to Build Location -> Per-configuration Build Products Path -> Staging and change Staging value from $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to $(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)*
|
|
36
|
+
|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
*NOTE: Due to https://github.com/facebook/react-native/issues/11813, we have to do this step to make it possible to use other configurations than Debug or Release on RN 0.40.0 or higher.*
|
|
40
|
+
|
|
41
|
+
8. Click the `+` button again on the toolbar and select `Add User-Defined Setting`
|
|
36
42
|
|
|
37
|
-
|
|
43
|
+
Name this new setting something like `CODEPUSH_KEY`, expand it, and specify your `Staging` deployment key for the `Staging` config and your `Production` deployment key for the `Release` config.
|
|
38
44
|
|
|
39
45
|

|
|
40
46
|
|
|
41
|
-
*NOTE: As a reminder, you can retrieve these keys by running `
|
|
47
|
+
*NOTE: As a reminder, you can retrieve these keys by running `appcenter codepush deployment list -a <ownerName>/<appName> -k` from your terminal.*
|
|
42
48
|
|
|
43
|
-
|
|
49
|
+
9. Open your project's `Info.plist` file and change the value of your `CodePushDeploymentKey` entry to `$(CODEPUSH_KEY)`
|
|
44
50
|
|
|
45
51
|

|
|
46
52
|
|
|
@@ -48,6 +54,6 @@ And that's it! Now when you run or build your app, your staging builds will auto
|
|
|
48
54
|
|
|
49
55
|
*NOTE: CocoaPods users may need to run `pod install` before building with their new release configuration.*
|
|
50
56
|
|
|
51
|
-
*Note: If you encounter the error message `ld: library not found for ...`, please consult [this issue](https://github.com/
|
|
57
|
+
*Note: If you encounter the error message `ld: library not found for ...`, please consult [this issue](https://github.com/microsoft/react-native-code-push/issues/426) for a possible solution.*
|
|
52
58
|
|
|
53
59
|
Additionally, if you want to give them seperate names and/or icons, you can modify the `Product Bundle Identifier`, `Product Name` and `Asset Catalog App Icon Set Name` build settings, which will allow your staging builds to be distinguishable from release builds when installed on the same device.
|