@appcircle/react-native-code-push 0.0.1-alpha.1
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/.config/CredScanSuppressions.json +14 -0
- package/AlertAdapter.js +24 -0
- package/CONTRIBUTING.md +134 -0
- package/CodePush.js +671 -0
- package/CodePush.podspec +27 -0
- package/LICENSE.md +13 -0
- package/README.md +439 -0
- package/SECURITY.md +41 -0
- package/android/build.gradle +50 -0
- package/android/codepush.gradle +162 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +20 -0
- package/android/gradlew +164 -0
- package/android/gradlew.bat +90 -0
- package/android/proguard-rules.pro +25 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePush.java +434 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +37 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +35 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +102 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushInstallMode.java +16 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +12 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushInvalidUpdateException.java +7 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushMalformedDataException.java +12 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +848 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushNotInitializedException.java +12 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushTelemetryManager.java +175 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushUnknownException.java +12 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +383 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushUpdateState.java +15 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +275 -0
- package/android/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +238 -0
- package/android/src/main/java/com/microsoft/codepush/react/DownloadProgress.java +30 -0
- package/android/src/main/java/com/microsoft/codepush/react/DownloadProgressCallback.java +5 -0
- package/android/src/main/java/com/microsoft/codepush/react/FileUtils.java +203 -0
- package/android/src/main/java/com/microsoft/codepush/react/ReactHostHolder.java +11 -0
- package/android/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +20 -0
- package/android/src/main/java/com/microsoft/codepush/react/SettingsManager.java +173 -0
- package/android/src/main/java/com/microsoft/codepush/react/TLSSocketFactory.java +72 -0
- package/docs/api-android.md +81 -0
- package/docs/api-ios.md +31 -0
- package/docs/api-js.md +592 -0
- package/docs/multi-deployment-testing-android.md +55 -0
- package/docs/multi-deployment-testing-ios.md +59 -0
- package/docs/setup-android.md +103 -0
- package/docs/setup-ios.md +109 -0
- package/docs/setup-windows.md +121 -0
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +34 -0
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +252 -0
- package/ios/CodePush/Base64/README.md +47 -0
- package/ios/CodePush/CodePush.h +235 -0
- package/ios/CodePush/CodePush.m +1122 -0
- package/ios/CodePush/CodePushConfig.m +116 -0
- package/ios/CodePush/CodePushDownloadHandler.m +130 -0
- package/ios/CodePush/CodePushErrorUtils.m +20 -0
- package/ios/CodePush/CodePushPackage.m +602 -0
- package/ios/CodePush/CodePushTelemetryManager.m +175 -0
- package/ios/CodePush/CodePushUpdateUtils.m +376 -0
- package/ios/CodePush/CodePushUtils.m +9 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +69 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +16 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +51 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +15 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +55 -0
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +24 -0
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +41 -0
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +28 -0
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +205 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +103 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +322 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +37 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +145 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +35 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +551 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +23 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +43 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +230 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +31 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +113 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +38 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +500 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +18 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +214 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +23 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +29 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +19 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +68 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +18 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +72 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +67 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +111 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +119 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +307 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +94 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +619 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +164 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +514 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +24 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +11 -0
- package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +52 -0
- package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +5 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +28 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +70 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +22 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +34 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +73 -0
- package/ios/CodePush/JWT/LICENSE +19 -0
- package/ios/CodePush/JWT/README.md +489 -0
- package/ios/CodePush/RCTConvert+CodePushInstallMode.m +20 -0
- package/ios/CodePush/RCTConvert+CodePushUpdateState.m +20 -0
- package/ios/CodePush/SSZipArchive/Info.plist +26 -0
- package/ios/CodePush/SSZipArchive/README.md +1 -0
- package/ios/CodePush/SSZipArchive/SSZipArchive.h +178 -0
- package/ios/CodePush/SSZipArchive/SSZipArchive.m +1496 -0
- package/ios/CodePush/SSZipArchive/SSZipCommon.h +71 -0
- package/ios/CodePush/SSZipArchive/Supporting Files/PrivacyInfo.xcprivacy +23 -0
- package/ios/CodePush/SSZipArchive/include/ZipArchive.h +25 -0
- package/ios/CodePush/SSZipArchive/minizip/LICENSE +17 -0
- package/ios/CodePush/SSZipArchive/minizip/mz.h +273 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_compat.c +1306 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_compat.h +346 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt.c +187 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt.h +65 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt_apple.c +526 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os.c +348 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os.h +176 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os_posix.c +350 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm.c +556 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm.h +132 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.c +383 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.h +42 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.c +269 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.h +48 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_os.h +40 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_os_posix.c +203 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.c +334 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.h +46 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.c +429 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.h +43 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.c +360 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.h +46 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.c +389 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.h +43 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip.c +2782 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip.h +262 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.c +1942 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.h +285 -0
- package/ios/CodePush.xcodeproj/project.pbxproj +1052 -0
- package/ios/CodePush.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/CodePush.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/PrivacyInfo.xcprivacy +31 -0
- package/logging.js +6 -0
- package/package-mixins.js +68 -0
- package/package.json +90 -0
- package/react-native.config.js +11 -0
- package/request-fetch-adapter.js +52 -0
- package/scripts/check-package.mjs +11 -0
- package/scripts/generateBundledResourcesHash.js +125 -0
- package/scripts/getFilesInFolder.js +19 -0
- package/scripts/postlink/android/postlink.js +87 -0
- package/scripts/postlink/ios/postlink.js +116 -0
- package/scripts/postlink/run.js +11 -0
- package/scripts/postunlink/android/postunlink.js +74 -0
- package/scripts/postunlink/ios/postunlink.js +87 -0
- package/scripts/postunlink/run.js +11 -0
- package/scripts/recordFilesBeforeBundleCommand.js +41 -0
- package/scripts/tools/linkToolsAndroid.js +57 -0
- package/scripts/tools/linkToolsIos.js +130 -0
- package/tsconfig.json +17 -0
- package/tslint.json +32 -0
- package/typings/react-native-code-push.d.ts +455 -0
- package/windows/CodePush/CodePush.def +3 -0
- package/windows/CodePush/CodePush.vcxproj +198 -0
- package/windows/CodePush/CodePush.vcxproj.filters +91 -0
- package/windows/CodePush/CodePushConfig.cpp +104 -0
- package/windows/CodePush/CodePushConfig.h +66 -0
- package/windows/CodePush/CodePushConfig.idl +12 -0
- package/windows/CodePush/CodePushDownloadHandler.cpp +73 -0
- package/windows/CodePush/CodePushDownloadHandler.h +32 -0
- package/windows/CodePush/CodePushNativeModule.cpp +934 -0
- package/windows/CodePush/CodePushNativeModule.h +247 -0
- package/windows/CodePush/CodePushPackage.cpp +456 -0
- package/windows/CodePush/CodePushPackage.h +49 -0
- package/windows/CodePush/CodePushTelemetryManager.cpp +213 -0
- package/windows/CodePush/CodePushTelemetryManager.h +29 -0
- package/windows/CodePush/CodePushUpdateUtils.cpp +86 -0
- package/windows/CodePush/CodePushUpdateUtils.h +38 -0
- package/windows/CodePush/CodePushUtils.cpp +29 -0
- package/windows/CodePush/CodePushUtils.h +18 -0
- package/windows/CodePush/FileUtils.cpp +131 -0
- package/windows/CodePush/FileUtils.h +28 -0
- package/windows/CodePush/PropertySheet.props +16 -0
- package/windows/CodePush/ReactPackageProvider.cpp +15 -0
- package/windows/CodePush/ReactPackageProvider.h +22 -0
- package/windows/CodePush/ReactPackageProvider.idl +9 -0
- package/windows/CodePush/miniz/LICENSE +22 -0
- package/windows/CodePush/miniz/miniz.c +7657 -0
- package/windows/CodePush/miniz/miniz.h +1338 -0
- package/windows/CodePush/miniz/readme.md +37 -0
- package/windows/CodePush/packages.config +4 -0
- package/windows/CodePush/pch.cpp +1 -0
- package/windows/CodePush/pch.h +4 -0
- package/windows-legacy/CodePush/CodePush.csproj +128 -0
- package/windows-legacy/CodePush/CodePushUtils.cs +47 -0
- package/windows-legacy/CodePush/FileUtils.cs +40 -0
- package/windows-legacy/CodePush/Properties/AssemblyInfo.cs +29 -0
- package/windows-legacy/CodePush/Properties/CodePush.rd.xml +33 -0
- package/windows-legacy/CodePush/UpdateManager.cs +305 -0
- package/windows-legacy/CodePush/UpdateUtils.cs +46 -0
- package/windows-legacy/CodePush.Net46/Adapters/Http/HttpProgress.cs +28 -0
- package/windows-legacy/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +106 -0
- package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +103 -0
- package/windows-legacy/CodePush.Net46/CodePushUtils.cs +158 -0
- package/windows-legacy/CodePush.Net46/FileUtils.cs +55 -0
- package/windows-legacy/CodePush.Net46/Properties/AssemblyInfo.cs +36 -0
- package/windows-legacy/CodePush.Net46/UpdateManager.cs +330 -0
- package/windows-legacy/CodePush.Net46/UpdateUtils.cs +70 -0
- package/windows-legacy/CodePush.Net46/packages.config +5 -0
- package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +105 -0
- package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +137 -0
- package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +36 -0
- package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +117 -0
- package/windows-legacy/CodePush.Net46.Test/app.config +11 -0
- package/windows-legacy/CodePush.Net46.Test/packages.config +4 -0
- package/windows-legacy/CodePush.Shared/CodePush.Shared.projitems +22 -0
- package/windows-legacy/CodePush.Shared/CodePush.Shared.shproj +13 -0
- package/windows-legacy/CodePush.Shared/CodePushConstants.cs +35 -0
- package/windows-legacy/CodePush.Shared/CodePushNativeModule.cs +329 -0
- package/windows-legacy/CodePush.Shared/CodePushReactPackage.cs +235 -0
- package/windows-legacy/CodePush.Shared/CodePushUtils.cs +70 -0
- package/windows-legacy/CodePush.Shared/InstallMode.cs +9 -0
- package/windows-legacy/CodePush.Shared/MinimumBackgroundListener.cs +44 -0
- package/windows-legacy/CodePush.Shared/SettingsManager.cs +148 -0
- package/windows-legacy/CodePush.Shared/TelemetryManager.cs +250 -0
- package/windows-legacy/CodePush.Shared/UpdateState.cs +9 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
package com.microsoft.codepush.react;
|
|
2
|
+
|
|
3
|
+
import java.io.BufferedInputStream;
|
|
4
|
+
import java.io.BufferedReader;
|
|
5
|
+
import java.io.File;
|
|
6
|
+
import java.io.FileInputStream;
|
|
7
|
+
import java.io.FileOutputStream;
|
|
8
|
+
import java.io.IOException;
|
|
9
|
+
import java.io.InputStreamReader;
|
|
10
|
+
import java.io.PrintWriter;
|
|
11
|
+
import java.util.zip.ZipEntry;
|
|
12
|
+
import java.util.zip.ZipInputStream;
|
|
13
|
+
|
|
14
|
+
public class FileUtils {
|
|
15
|
+
|
|
16
|
+
private static final int WRITE_BUFFER_SIZE = 1024 * 8;
|
|
17
|
+
|
|
18
|
+
public static void copyDirectoryContents(String sourceDirectoryPath, String destinationDirectoryPath) throws IOException {
|
|
19
|
+
File sourceDir = new File(sourceDirectoryPath);
|
|
20
|
+
File destDir = new File(destinationDirectoryPath);
|
|
21
|
+
if (!destDir.exists()) {
|
|
22
|
+
destDir.mkdir();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (File sourceFile : sourceDir.listFiles()) {
|
|
26
|
+
if (sourceFile.isDirectory()) {
|
|
27
|
+
copyDirectoryContents(
|
|
28
|
+
CodePushUtils.appendPathComponent(sourceDirectoryPath, sourceFile.getName()),
|
|
29
|
+
CodePushUtils.appendPathComponent(destinationDirectoryPath, sourceFile.getName()));
|
|
30
|
+
} else {
|
|
31
|
+
File destFile = new File(destDir, sourceFile.getName());
|
|
32
|
+
FileInputStream fromFileStream = null;
|
|
33
|
+
BufferedInputStream fromBufferedStream = null;
|
|
34
|
+
FileOutputStream destStream = null;
|
|
35
|
+
byte[] buffer = new byte[WRITE_BUFFER_SIZE];
|
|
36
|
+
try {
|
|
37
|
+
fromFileStream = new FileInputStream(sourceFile);
|
|
38
|
+
fromBufferedStream = new BufferedInputStream(fromFileStream);
|
|
39
|
+
destStream = new FileOutputStream(destFile);
|
|
40
|
+
int bytesRead;
|
|
41
|
+
while ((bytesRead = fromBufferedStream.read(buffer)) > 0) {
|
|
42
|
+
destStream.write(buffer, 0, bytesRead);
|
|
43
|
+
}
|
|
44
|
+
} finally {
|
|
45
|
+
try {
|
|
46
|
+
if (fromFileStream != null) fromFileStream.close();
|
|
47
|
+
if (fromBufferedStream != null) fromBufferedStream.close();
|
|
48
|
+
if (destStream != null) destStream.close();
|
|
49
|
+
} catch (IOException e) {
|
|
50
|
+
throw new CodePushUnknownException("Error closing IO resources.", e);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public static void deleteDirectoryAtPath(String directoryPath) {
|
|
58
|
+
if (directoryPath == null) {
|
|
59
|
+
CodePushUtils.log("deleteDirectoryAtPath attempted with null directoryPath");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
File file = new File(directoryPath);
|
|
63
|
+
if (file.exists()) {
|
|
64
|
+
deleteFileOrFolderSilently(file);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public static void deleteFileAtPathSilently(String path) {
|
|
69
|
+
deleteFileOrFolderSilently(new File(path));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public static void deleteFileOrFolderSilently(File file) {
|
|
73
|
+
if (file.isDirectory()) {
|
|
74
|
+
File[] files = file.listFiles();
|
|
75
|
+
for (File fileEntry : files) {
|
|
76
|
+
if (fileEntry.isDirectory()) {
|
|
77
|
+
deleteFileOrFolderSilently(fileEntry);
|
|
78
|
+
} else {
|
|
79
|
+
fileEntry.delete();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!file.delete()) {
|
|
85
|
+
CodePushUtils.log("Error deleting file " + file.getName());
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public static boolean fileAtPathExists(String filePath) {
|
|
90
|
+
return new File(filePath).exists();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public static void moveFile(File fileToMove, String newFolderPath, String newFileName) {
|
|
94
|
+
File newFolder = new File(newFolderPath);
|
|
95
|
+
if (!newFolder.exists()) {
|
|
96
|
+
newFolder.mkdirs();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
File newFilePath = new File(newFolderPath, newFileName);
|
|
100
|
+
if (!fileToMove.renameTo(newFilePath)) {
|
|
101
|
+
throw new CodePushUnknownException("Unable to move file from " +
|
|
102
|
+
fileToMove.getAbsolutePath() + " to " + newFilePath.getAbsolutePath() + ".");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public static String readFileToString(String filePath) throws IOException {
|
|
107
|
+
FileInputStream fin = null;
|
|
108
|
+
BufferedReader reader = null;
|
|
109
|
+
try {
|
|
110
|
+
File fl = new File(filePath);
|
|
111
|
+
fin = new FileInputStream(fl);
|
|
112
|
+
reader = new BufferedReader(new InputStreamReader(fin));
|
|
113
|
+
StringBuilder sb = new StringBuilder();
|
|
114
|
+
String line = null;
|
|
115
|
+
while ((line = reader.readLine()) != null) {
|
|
116
|
+
sb.append(line).append("\n");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return sb.toString();
|
|
120
|
+
} finally {
|
|
121
|
+
if (reader != null) reader.close();
|
|
122
|
+
if (fin != null) fin.close();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private static String validateFileName(String fileName, File destinationFolder) throws IOException {
|
|
127
|
+
String destinationFolderCanonicalPath = destinationFolder.getCanonicalPath() + File.separator;
|
|
128
|
+
|
|
129
|
+
File file = new File(destinationFolderCanonicalPath, fileName);
|
|
130
|
+
String canonicalPath = file.getCanonicalPath();
|
|
131
|
+
|
|
132
|
+
if (!canonicalPath.startsWith(destinationFolderCanonicalPath)) {
|
|
133
|
+
throw new IllegalStateException("File is outside extraction target directory.");
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return canonicalPath;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public static void unzipFile(File zipFile, String destination) throws IOException {
|
|
140
|
+
FileInputStream fileStream = null;
|
|
141
|
+
BufferedInputStream bufferedStream = null;
|
|
142
|
+
ZipInputStream zipStream = null;
|
|
143
|
+
try {
|
|
144
|
+
fileStream = new FileInputStream(zipFile);
|
|
145
|
+
bufferedStream = new BufferedInputStream(fileStream);
|
|
146
|
+
zipStream = new ZipInputStream(bufferedStream);
|
|
147
|
+
ZipEntry entry;
|
|
148
|
+
|
|
149
|
+
File destinationFolder = new File(destination);
|
|
150
|
+
if (destinationFolder.exists()) {
|
|
151
|
+
deleteFileOrFolderSilently(destinationFolder);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
destinationFolder.mkdirs();
|
|
155
|
+
|
|
156
|
+
byte[] buffer = new byte[WRITE_BUFFER_SIZE];
|
|
157
|
+
while ((entry = zipStream.getNextEntry()) != null) {
|
|
158
|
+
String fileName = validateFileName(entry.getName(), destinationFolder);
|
|
159
|
+
File file = new File(fileName);
|
|
160
|
+
if (entry.isDirectory()) {
|
|
161
|
+
file.mkdirs();
|
|
162
|
+
} else {
|
|
163
|
+
File parent = file.getParentFile();
|
|
164
|
+
if (!parent.exists()) {
|
|
165
|
+
parent.mkdirs();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
FileOutputStream fout = new FileOutputStream(file);
|
|
169
|
+
try {
|
|
170
|
+
int numBytesRead;
|
|
171
|
+
while ((numBytesRead = zipStream.read(buffer)) != -1) {
|
|
172
|
+
fout.write(buffer, 0, numBytesRead);
|
|
173
|
+
}
|
|
174
|
+
} finally {
|
|
175
|
+
fout.close();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
long time = entry.getTime();
|
|
179
|
+
if (time > 0) {
|
|
180
|
+
file.setLastModified(time);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
} finally {
|
|
184
|
+
try {
|
|
185
|
+
if (zipStream != null) zipStream.close();
|
|
186
|
+
if (bufferedStream != null) bufferedStream.close();
|
|
187
|
+
if (fileStream != null) fileStream.close();
|
|
188
|
+
} catch (IOException e) {
|
|
189
|
+
throw new CodePushUnknownException("Error closing IO resources.", e);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
public static void writeStringToFile(String content, String filePath) throws IOException {
|
|
195
|
+
PrintWriter out = null;
|
|
196
|
+
try {
|
|
197
|
+
out = new PrintWriter(filePath);
|
|
198
|
+
out.print(content);
|
|
199
|
+
} finally {
|
|
200
|
+
if (out != null) out.close();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
package com.microsoft.codepush.react;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactHost;
|
|
4
|
+
import com.facebook.react.runtime.ReactHostDelegate;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Provides access to a {@link ReactHostDelegate}
|
|
8
|
+
*/
|
|
9
|
+
public interface ReactHostHolder {
|
|
10
|
+
ReactHost getReactHost();
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package com.microsoft.codepush.react;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactInstanceManager;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Provides access to a {@link ReactInstanceManager}.
|
|
7
|
+
*
|
|
8
|
+
* ReactNativeHost already implements this interface, if you make use of that react-native
|
|
9
|
+
* component (just add `implements ReactInstanceHolder`).
|
|
10
|
+
*/
|
|
11
|
+
public interface ReactInstanceHolder {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get the current {@link ReactInstanceManager} instance. May return null.
|
|
15
|
+
*/
|
|
16
|
+
ReactInstanceManager getReactInstanceManager();
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
package com.microsoft.codepush.react;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.SharedPreferences;
|
|
5
|
+
|
|
6
|
+
import org.json.JSONArray;
|
|
7
|
+
import org.json.JSONException;
|
|
8
|
+
import org.json.JSONObject;
|
|
9
|
+
|
|
10
|
+
public class SettingsManager {
|
|
11
|
+
|
|
12
|
+
private SharedPreferences mSettings;
|
|
13
|
+
|
|
14
|
+
public SettingsManager(Context applicationContext) {
|
|
15
|
+
mSettings = applicationContext.getSharedPreferences(CodePushConstants.CODE_PUSH_PREFERENCES, 0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public JSONArray getFailedUpdates() {
|
|
19
|
+
String failedUpdatesString = mSettings.getString(CodePushConstants.FAILED_UPDATES_KEY, null);
|
|
20
|
+
if (failedUpdatesString == null) {
|
|
21
|
+
return new JSONArray();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
return new JSONArray(failedUpdatesString);
|
|
26
|
+
} catch (JSONException e) {
|
|
27
|
+
// Unrecognized data format, clear and replace with expected format.
|
|
28
|
+
JSONArray emptyArray = new JSONArray();
|
|
29
|
+
mSettings.edit().putString(CodePushConstants.FAILED_UPDATES_KEY, emptyArray.toString()).commit();
|
|
30
|
+
return emptyArray;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public JSONObject getPendingUpdate() {
|
|
35
|
+
String pendingUpdateString = mSettings.getString(CodePushConstants.PENDING_UPDATE_KEY, null);
|
|
36
|
+
if (pendingUpdateString == null) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
return new JSONObject(pendingUpdateString);
|
|
42
|
+
} catch (JSONException e) {
|
|
43
|
+
// Should not happen.
|
|
44
|
+
CodePushUtils.log("Unable to parse pending update metadata " + pendingUpdateString +
|
|
45
|
+
" stored in SharedPreferences");
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
public boolean isFailedHash(String packageHash) {
|
|
52
|
+
JSONArray failedUpdates = getFailedUpdates();
|
|
53
|
+
if (packageHash != null) {
|
|
54
|
+
for (int i = 0; i < failedUpdates.length(); i++) {
|
|
55
|
+
try {
|
|
56
|
+
JSONObject failedPackage = failedUpdates.getJSONObject(i);
|
|
57
|
+
String failedPackageHash = failedPackage.getString(CodePushConstants.PACKAGE_HASH_KEY);
|
|
58
|
+
if (packageHash.equals(failedPackageHash)) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
} catch (JSONException e) {
|
|
62
|
+
throw new CodePushUnknownException("Unable to read failedUpdates data stored in SharedPreferences.", e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public boolean isPendingUpdate(String packageHash) {
|
|
71
|
+
JSONObject pendingUpdate = getPendingUpdate();
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
return pendingUpdate != null &&
|
|
75
|
+
!pendingUpdate.getBoolean(CodePushConstants.PENDING_UPDATE_IS_LOADING_KEY) &&
|
|
76
|
+
(packageHash == null || pendingUpdate.getString(CodePushConstants.PENDING_UPDATE_HASH_KEY).equals(packageHash));
|
|
77
|
+
} catch (JSONException e) {
|
|
78
|
+
throw new CodePushUnknownException("Unable to read pending update metadata in isPendingUpdate.", e);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public void removeFailedUpdates() {
|
|
83
|
+
mSettings.edit().remove(CodePushConstants.FAILED_UPDATES_KEY).commit();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public void removePendingUpdate() {
|
|
87
|
+
mSettings.edit().remove(CodePushConstants.PENDING_UPDATE_KEY).commit();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public void saveFailedUpdate(JSONObject failedPackage) {
|
|
91
|
+
try {
|
|
92
|
+
if (isFailedHash(failedPackage.getString(CodePushConstants.PACKAGE_HASH_KEY))) {
|
|
93
|
+
// Do not need to add the package if it is already in the failedUpdates.
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
} catch (JSONException e) {
|
|
97
|
+
throw new CodePushUnknownException("Unable to read package hash from package.", e);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
String failedUpdatesString = mSettings.getString(CodePushConstants.FAILED_UPDATES_KEY, null);
|
|
101
|
+
JSONArray failedUpdates;
|
|
102
|
+
if (failedUpdatesString == null) {
|
|
103
|
+
failedUpdates = new JSONArray();
|
|
104
|
+
} else {
|
|
105
|
+
try {
|
|
106
|
+
failedUpdates = new JSONArray(failedUpdatesString);
|
|
107
|
+
} catch (JSONException e) {
|
|
108
|
+
// Should not happen.
|
|
109
|
+
throw new CodePushMalformedDataException("Unable to parse failed updates information " +
|
|
110
|
+
failedUpdatesString + " stored in SharedPreferences", e);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
failedUpdates.put(failedPackage);
|
|
115
|
+
mSettings.edit().putString(CodePushConstants.FAILED_UPDATES_KEY, failedUpdates.toString()).commit();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public JSONObject getLatestRollbackInfo() {
|
|
119
|
+
String latestRollbackInfoString = mSettings.getString(CodePushConstants.LATEST_ROLLBACK_INFO_KEY, null);
|
|
120
|
+
if (latestRollbackInfoString == null) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
return new JSONObject(latestRollbackInfoString);
|
|
126
|
+
} catch (JSONException e) {
|
|
127
|
+
// Should not happen.
|
|
128
|
+
CodePushUtils.log("Unable to parse latest rollback metadata " + latestRollbackInfoString +
|
|
129
|
+
" stored in SharedPreferences");
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public void setLatestRollbackInfo(String packageHash) {
|
|
135
|
+
JSONObject latestRollbackInfo = getLatestRollbackInfo();
|
|
136
|
+
int count = 0;
|
|
137
|
+
|
|
138
|
+
if (latestRollbackInfo != null) {
|
|
139
|
+
try {
|
|
140
|
+
String latestRollbackPackageHash = latestRollbackInfo.getString(CodePushConstants.LATEST_ROLLBACK_PACKAGE_HASH_KEY);
|
|
141
|
+
if (latestRollbackPackageHash.equals(packageHash)) {
|
|
142
|
+
count = latestRollbackInfo.getInt(CodePushConstants.LATEST_ROLLBACK_COUNT_KEY);
|
|
143
|
+
}
|
|
144
|
+
} catch (JSONException e) {
|
|
145
|
+
CodePushUtils.log("Unable to parse latest rollback info.");
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
latestRollbackInfo = new JSONObject();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
latestRollbackInfo.put(CodePushConstants.LATEST_ROLLBACK_PACKAGE_HASH_KEY, packageHash);
|
|
153
|
+
latestRollbackInfo.put(CodePushConstants.LATEST_ROLLBACK_TIME_KEY, System.currentTimeMillis());
|
|
154
|
+
latestRollbackInfo.put(CodePushConstants.LATEST_ROLLBACK_COUNT_KEY, count + 1);
|
|
155
|
+
mSettings.edit().putString(CodePushConstants.LATEST_ROLLBACK_INFO_KEY, latestRollbackInfo.toString()).commit();
|
|
156
|
+
} catch (JSONException e) {
|
|
157
|
+
throw new CodePushUnknownException("Unable to save latest rollback info.", e);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
public void savePendingUpdate(String packageHash, boolean isLoading) {
|
|
162
|
+
JSONObject pendingUpdate = new JSONObject();
|
|
163
|
+
try {
|
|
164
|
+
pendingUpdate.put(CodePushConstants.PENDING_UPDATE_HASH_KEY, packageHash);
|
|
165
|
+
pendingUpdate.put(CodePushConstants.PENDING_UPDATE_IS_LOADING_KEY, isLoading);
|
|
166
|
+
mSettings.edit().putString(CodePushConstants.PENDING_UPDATE_KEY, pendingUpdate.toString()).commit();
|
|
167
|
+
} catch (JSONException e) {
|
|
168
|
+
// Should not happen.
|
|
169
|
+
throw new CodePushUnknownException("Unable to save pending update.", e);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
### Resource Configuration
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
* __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.
|
|
6
|
+
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:
|
|
7
|
+
```xml
|
|
8
|
+
<string moduleConfig="true" name="CodePushPublicKey">your-public-key</string>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
* __Server Url__ - used for specifying CodePush Server Url.
|
|
12
|
+
The Default value: "https://codepush.appcenter.ms/" 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:
|
|
13
|
+
```xml
|
|
14
|
+
<string moduleConfig="true" name="CodePushServerUrl">https://yourcodepush.server.com</string>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
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`.
|
|
18
|
+
|
|
19
|
+
### Java API Reference (Android)
|
|
20
|
+
|
|
21
|
+
#### CodePush
|
|
22
|
+
|
|
23
|
+
Constructs the CodePush client runtime and represents the `ReactPackage` instance that you add to you app's list of packages.
|
|
24
|
+
|
|
25
|
+
##### Constructors
|
|
26
|
+
|
|
27
|
+
- __CodePush(String deploymentKey, Activity mainActivity)__ - Creates a new instance of the CodePush runtime, that will be used to query the service for updates via the provided deployment key. The `mainActivity` parameter should always be set to `this` when configuring your React packages list inside the `MainActivity` class. This constructor puts the CodePush runtime into "release mode", so if you want to enable debugging behavior, use the following constructor instead.
|
|
28
|
+
|
|
29
|
+
- __CodePush(String deploymentKey, Activity mainActivity, bool isDebugMode)__ - Equivalent to the previous constructor but allows you to specify whether you want the CodePush runtime to be in debug mode or not. When using this constructor, the `isDebugMode` parameter should always be set to `BuildConfig.DEBUG` in order to stay synchronized with your build type. When putting CodePush into debug mode, the following behaviors are enabled:
|
|
30
|
+
|
|
31
|
+
1. Old CodePush updates aren't deleted from storage whenever a new binary is deployed to the emulator/device. This behavior enables you to deploy new binaries, without bumping the version during development, and without continuously getting the same update every time your app calls `sync`.
|
|
32
|
+
|
|
33
|
+
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.
|
|
34
|
+
|
|
35
|
+
- __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.
|
|
36
|
+
|
|
37
|
+
- __CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl)__ Constructor allows you to specify CodePush Server Url. The Default value: `"https://codepush.appcenter.ms/"` is overridden by value specified in `serverUrl`.
|
|
38
|
+
|
|
39
|
+
##### Builder
|
|
40
|
+
|
|
41
|
+
As an alternative to constructors *you can also use `CodePushBuilder`* to setup a CodePush instance configured with *only parameters you want*.
|
|
42
|
+
|
|
43
|
+
```java
|
|
44
|
+
@Override
|
|
45
|
+
protected List<ReactPackage> getPackages() {
|
|
46
|
+
return Arrays.<ReactPackage>asList(
|
|
47
|
+
new MainReactPackage(),
|
|
48
|
+
new CodePushBuilder("deployment-key-here",getApplicationContext())
|
|
49
|
+
.setIsDebugMode(BuildConfig.DEBUG)
|
|
50
|
+
.setPublicKeyResourceDescriptor(R.string.publicKey)
|
|
51
|
+
.setServerUrl("https://yourcodepush.server.com")
|
|
52
|
+
.build() //return configured CodePush instance
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`CodePushBuilder` methods:
|
|
58
|
+
|
|
59
|
+
* __public CodePushBuilder(String deploymentKey, Context context)__ - setup same parameters as via __CodePush(String deploymentKey, Activity mainActivity)__
|
|
60
|
+
|
|
61
|
+
* __public CodePushBuilder setIsDebugMode(boolean isDebugMode)__ - allows you to specify whether you want the CodePush runtime to be in debug mode or not. Default value: `false`.
|
|
62
|
+
|
|
63
|
+
* __public CodePushBuilder setServerUrl(String serverUrl)__ - allows you to specify CodePush Server Url. Default value: `"https://codepush.appcenter.ms/"`.
|
|
64
|
+
|
|
65
|
+
* __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.
|
|
66
|
+
|
|
67
|
+
* __public CodePush build()__ - return configured `CodePush` instance.
|
|
68
|
+
|
|
69
|
+
##### Public Methods
|
|
70
|
+
|
|
71
|
+
- __setDeploymentKey(String deploymentKey)__ - Sets the deployment key that the app should use when querying for updates. This is a dynamic alternative to setting the deployment key in Codepush constructor/builder and/or specifying a deployment key in JS when calling `checkForUpdate` or `sync`.
|
|
72
|
+
|
|
73
|
+
##### Static Methods
|
|
74
|
+
|
|
75
|
+
- __getBundleUrl()__ - Returns the path to the most recent version of your app's JS bundle file, assuming that the resource name is `index.android.bundle`. If your app is using a different bundle name, then use the overloaded version of this method which allows specifying it. This method has the same resolution behavior as the Objective-C equivalent described above.
|
|
76
|
+
|
|
77
|
+
- __getBundleUrl(String bundleName)__ - Returns the path to the most recent version of your app's JS bundle file, using the specified resource name (like `index.android.bundle`). This method has the same resolution behavior as the Objective-C equivalent described above.
|
|
78
|
+
|
|
79
|
+
- __getPackageFolder()__ - Returns the path to the current update folder.
|
|
80
|
+
|
|
81
|
+
- __overrideAppVersion(String appVersionOverride)__ - Sets the version of the application's binary interface, which would otherwise default to the Play Store version specified as the `versionName` in the `build.gradle`. This should be called a single time, before the CodePush instance is constructed.
|
package/docs/api-ios.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
### Objective-C API Reference (iOS)
|
|
2
|
+
|
|
3
|
+
The Objective-C API is made available by importing the `CodePush.h` header into your `AppDelegate.m` file, and consists of a single public class named `CodePush`.
|
|
4
|
+
|
|
5
|
+
#### CodePush
|
|
6
|
+
|
|
7
|
+
Contains static methods for retreiving the `NSURL` that represents the most recent JavaScript bundle file, and can be passed to the `RCTRootView`'s `initWithBundleURL` method when bootstrapping your app in the `AppDelegate.m` file.
|
|
8
|
+
|
|
9
|
+
The `CodePush` class' methods can be thought of as composite resolvers which always load the appropriate bundle, in order to accommodate the following scenarios:
|
|
10
|
+
|
|
11
|
+
1. When an end-user installs your app from the store (like `1.0.0`), they will get the JS bundle that is contained within the binary. This is the behavior you would get without using CodePush, but we make sure it doesn't break :)
|
|
12
|
+
|
|
13
|
+
2. As soon as you begin releasing CodePush updates, your end-users will get the JS bundle that represents the latest release for the configured deployment. This is the behavior that allows you to iterate beyond what you shipped to the store.
|
|
14
|
+
|
|
15
|
+
3. As soon as you release an update to the app store (like `1.1.0`), and your end-users update it, they will once again get the JS bundle that is contained within the binary. This behavior ensures that CodePush updates that targetted a previous binary version aren't used (since we don't know if they would work), and your end-users always have a working version of your app.
|
|
16
|
+
|
|
17
|
+
4. Repeat #2 and #3 as the CodePush releases and app store releases continue on into infinity (and beyond?)
|
|
18
|
+
|
|
19
|
+
Because of this behavior, you can safely deploy updates to both the app store(s) and CodePush as necesary, and rest assured that your end-users will always get the most recent version.
|
|
20
|
+
|
|
21
|
+
##### Methods
|
|
22
|
+
|
|
23
|
+
- __(NSURL \*)bundleURL__ - Returns the most recent JS bundle `NSURL` as described above. This method assumes that the name of the JS bundle contained within your app binary is `main.jsbundle`.
|
|
24
|
+
|
|
25
|
+
- __(NSURL \*)bundleURLForResource:(NSString \*)resourceName__ - Equivalent to the `bundleURL` method, but also allows customizing the name of the JS bundle that is looked for within the app binary. This is useful if you aren't naming this file `main` (which is the default convention). This method assumes that the JS bundle's extension is `*.jsbundle`.
|
|
26
|
+
|
|
27
|
+
- __(NSURL \*)bundleURLForResource:(NSString \*)resourceName withExtension:(NSString \*)resourceExtension__: Equivalent to the `bundleURLForResource:` method, but also allows customizing the extension used by the JS bundle that is looked for within the app binary. This is useful if you aren't naming this file `*.jsbundle` (which is the default convention).
|
|
28
|
+
|
|
29
|
+
- __(void)overrideAppVersion:(NSString \*)appVersionOverride__ - Sets the version of the application's binary interface, which would otherwise default to the App Store version specified as the `CFBundleShortVersionString` in the `Info.plist`. This should be called a single time, before the bundle URL is loaded.
|
|
30
|
+
|
|
31
|
+
- __(void)setDeploymentKey:(NSString \*)deploymentKey__ - Sets the deployment key that the app should use when querying for updates. This is a dynamic alternative to setting the deployment key in your `Info.plist` and/or specifying a deployment key in JS when calling `checkForUpdate` or `sync`.
|