@appzung/react-native-code-push 10.0.0-rc1 → 10.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/CodePush.podspec +1 -0
- package/LICENSE.md +2 -2
- package/README.md +74 -95
- package/android/app/build.gradle +62 -18
- package/android/app/src/main/AndroidManifest.xml +2 -3
- package/android/app/src/main/AndroidManifestNew.xml +3 -0
- package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePush.java +21 -89
- package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushNativeModule.java +32 -3
- package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushUpdateManager.java +2 -2
- package/android/build.gradle +1 -11
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/gradle.properties +4 -20
- package/docs/advanced-usage.md +2 -2
- package/docs/api-android.md +12 -10
- package/docs/api-ios.md +5 -5
- package/docs/api-js.md +180 -178
- package/docs/code-signing.md +62 -0
- package/docs/migrating-to-v10.md +31 -0
- package/docs/setup-android.md +52 -79
- package/docs/setup-ios.md +31 -28
- package/docs/setup-windows.md +1 -0
- package/ios/CodePush/CodePush.m +13 -57
- package/lib/commonjs/CodePush.js +90 -0
- package/lib/commonjs/CodePush.js.map +1 -0
- package/lib/commonjs/allowRestart.js +12 -0
- package/lib/commonjs/allowRestart.js.map +1 -0
- package/lib/commonjs/checkForUpdates.js +105 -0
- package/lib/commonjs/checkForUpdates.js.map +1 -0
- package/lib/commonjs/clearUpdates.js +15 -0
- package/lib/commonjs/clearUpdates.js.map +1 -0
- package/lib/commonjs/disallowRestart.js +12 -0
- package/lib/commonjs/disallowRestart.js.map +1 -0
- package/lib/commonjs/enums/CheckFrequency.enum.js +25 -0
- package/lib/commonjs/enums/CheckFrequency.enum.js.map +1 -0
- package/lib/commonjs/enums/DeploymentStatus.enum.js +21 -0
- package/lib/commonjs/enums/DeploymentStatus.enum.js.map +1 -0
- package/lib/commonjs/enums/InstallMode.enum.js +35 -0
- package/lib/commonjs/enums/InstallMode.enum.js.map +1 -0
- package/lib/commonjs/enums/SyncStatus.enum.js +53 -0
- package/lib/commonjs/enums/SyncStatus.enum.js.map +1 -0
- package/lib/commonjs/enums/UpdateState.enum.js +29 -0
- package/lib/commonjs/enums/UpdateState.enum.js.map +1 -0
- package/lib/commonjs/getUpdateMetadata.js +25 -0
- package/lib/commonjs/getUpdateMetadata.js.map +1 -0
- package/lib/commonjs/index.js +195 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/internals/AcquisitionSdk.js +9 -0
- package/lib/commonjs/internals/AcquisitionSdk.js.map +1 -0
- package/lib/commonjs/internals/LocalPackageImplementation.js +29 -0
- package/lib/commonjs/internals/LocalPackageImplementation.js.map +1 -0
- package/lib/commonjs/internals/NativeRNAppZungCodePushModule.js +8 -0
- package/lib/commonjs/internals/NativeRNAppZungCodePushModule.js.map +1 -0
- package/lib/commonjs/internals/RNAppZungCodePushModuleSpec.js +6 -0
- package/lib/commonjs/internals/RNAppZungCodePushModuleSpec.js.map +1 -0
- package/lib/commonjs/internals/RemotePackageImplementation.js +49 -0
- package/lib/commonjs/internals/RemotePackageImplementation.js.map +1 -0
- package/lib/commonjs/internals/getConfiguration.js +15 -0
- package/lib/commonjs/internals/getConfiguration.js.map +1 -0
- package/lib/commonjs/internals/getCurrentPackage.js +12 -0
- package/lib/commonjs/internals/getCurrentPackage.js.map +1 -0
- package/lib/commonjs/internals/getPromisifiedSdk.js +49 -0
- package/lib/commonjs/internals/getPromisifiedSdk.js.map +1 -0
- package/lib/commonjs/internals/shouldUpdateBeIgnored.js +62 -0
- package/lib/commonjs/internals/shouldUpdateBeIgnored.js.map +1 -0
- package/lib/commonjs/internals/types.js +6 -0
- package/lib/commonjs/internals/types.js.map +1 -0
- package/lib/commonjs/internals/utils/log.js +11 -0
- package/lib/commonjs/internals/utils/log.js.map +1 -0
- package/lib/commonjs/internals/utils/request-fetch-adapter.js +50 -0
- package/lib/commonjs/internals/utils/request-fetch-adapter.js.map +1 -0
- package/lib/commonjs/internals/version.js +9 -0
- package/lib/commonjs/internals/version.js.map +1 -0
- package/lib/commonjs/notifyAppReady.js +83 -0
- package/lib/commonjs/notifyAppReady.js.map +1 -0
- package/lib/commonjs/reactNative.d.js +2 -0
- package/lib/commonjs/reactNative.d.js.map +1 -0
- package/lib/commonjs/restartApp.js +16 -0
- package/lib/commonjs/restartApp.js.map +1 -0
- package/lib/commonjs/sync.js +219 -0
- package/lib/commonjs/sync.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/CodePush.js +84 -0
- package/lib/module/CodePush.js.map +1 -0
- package/lib/module/allowRestart.js +9 -0
- package/lib/module/allowRestart.js.map +1 -0
- package/lib/module/checkForUpdates.js +101 -0
- package/lib/module/checkForUpdates.js.map +1 -0
- package/lib/module/clearUpdates.js +12 -0
- package/lib/module/clearUpdates.js.map +1 -0
- package/lib/module/disallowRestart.js +9 -0
- package/lib/module/disallowRestart.js.map +1 -0
- package/lib/module/enums/CheckFrequency.enum.js +21 -0
- package/lib/module/enums/CheckFrequency.enum.js.map +1 -0
- package/lib/module/enums/DeploymentStatus.enum.js +17 -0
- package/lib/module/enums/DeploymentStatus.enum.js.map +1 -0
- package/lib/module/enums/InstallMode.enum.js +32 -0
- package/lib/module/enums/InstallMode.enum.js.map +1 -0
- package/lib/module/enums/SyncStatus.enum.js +49 -0
- package/lib/module/enums/SyncStatus.enum.js.map +1 -0
- package/lib/module/enums/UpdateState.enum.js +26 -0
- package/lib/module/enums/UpdateState.enum.js.map +1 -0
- package/lib/module/getUpdateMetadata.js +21 -0
- package/lib/module/getUpdateMetadata.js.map +1 -0
- package/lib/module/index.js +19 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/internals/AcquisitionSdk.js +5 -0
- package/lib/module/internals/AcquisitionSdk.js.map +1 -0
- package/lib/module/internals/LocalPackageImplementation.js +24 -0
- package/lib/module/internals/LocalPackageImplementation.js.map +1 -0
- package/lib/module/internals/NativeRNAppZungCodePushModule.js +4 -0
- package/lib/module/internals/NativeRNAppZungCodePushModule.js.map +1 -0
- package/lib/module/internals/RNAppZungCodePushModuleSpec.js +4 -0
- package/lib/module/internals/RNAppZungCodePushModuleSpec.js.map +1 -0
- package/lib/module/internals/RemotePackageImplementation.js +44 -0
- package/lib/module/internals/RemotePackageImplementation.js.map +1 -0
- package/lib/module/internals/getConfiguration.js +11 -0
- package/lib/module/internals/getConfiguration.js.map +1 -0
- package/lib/module/internals/getCurrentPackage.js +8 -0
- package/lib/module/internals/getCurrentPackage.js.map +1 -0
- package/lib/module/internals/getPromisifiedSdk.js +45 -0
- package/lib/module/internals/getPromisifiedSdk.js.map +1 -0
- package/lib/module/internals/shouldUpdateBeIgnored.js +58 -0
- package/lib/module/internals/shouldUpdateBeIgnored.js.map +1 -0
- package/lib/module/internals/types.js +4 -0
- package/lib/module/internals/types.js.map +1 -0
- package/lib/module/internals/utils/log.js +7 -0
- package/lib/module/internals/utils/log.js.map +1 -0
- package/lib/module/internals/utils/request-fetch-adapter.js +46 -0
- package/lib/module/internals/utils/request-fetch-adapter.js.map +1 -0
- package/lib/module/internals/version.js +5 -0
- package/lib/module/internals/version.js.map +1 -0
- package/lib/module/notifyAppReady.js +79 -0
- package/lib/module/notifyAppReady.js.map +1 -0
- package/lib/module/reactNative.d.js +2 -0
- package/lib/module/reactNative.d.js.map +1 -0
- package/lib/module/restartApp.js +13 -0
- package/lib/module/restartApp.js.map +1 -0
- package/lib/module/sync.js +215 -0
- package/lib/module/sync.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/CodePush.d.ts +24 -0
- package/lib/typescript/commonjs/src/CodePush.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/allowRestart.d.ts +5 -0
- package/lib/typescript/commonjs/src/allowRestart.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/checkForUpdates.d.ts +9 -0
- package/lib/typescript/commonjs/src/checkForUpdates.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/clearUpdates.d.ts +8 -0
- package/lib/typescript/commonjs/src/clearUpdates.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/disallowRestart.d.ts +5 -0
- package/lib/typescript/commonjs/src/disallowRestart.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/enums/CheckFrequency.enum.d.ts +18 -0
- package/lib/typescript/commonjs/src/enums/CheckFrequency.enum.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts +14 -0
- package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/enums/InstallMode.enum.d.ts +27 -0
- package/lib/typescript/commonjs/src/enums/InstallMode.enum.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/enums/SyncStatus.enum.d.ts +46 -0
- package/lib/typescript/commonjs/src/enums/SyncStatus.enum.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/enums/UpdateState.enum.d.ts +21 -0
- package/lib/typescript/commonjs/src/enums/UpdateState.enum.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/getUpdateMetadata.d.ts +9 -0
- package/lib/typescript/commonjs/src/getUpdateMetadata.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +17 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts +3 -0
- package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/LocalPackageImplementation.d.ts +17 -0
- package/lib/typescript/commonjs/src/internals/LocalPackageImplementation.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/NativeRNAppZungCodePushModule.d.ts +3 -0
- package/lib/typescript/commonjs/src/internals/NativeRNAppZungCodePushModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts +36 -0
- package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts +18 -0
- package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/getConfiguration.d.ts +3 -0
- package/lib/typescript/commonjs/src/internals/getConfiguration.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/getCurrentPackage.d.ts +2 -0
- package/lib/typescript/commonjs/src/internals/getCurrentPackage.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts +13 -0
- package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/shouldUpdateBeIgnored.d.ts +3 -0
- package/lib/typescript/commonjs/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/types.d.ts +16 -0
- package/lib/typescript/commonjs/src/internals/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/utils/log.d.ts +2 -0
- package/lib/typescript/commonjs/src/internals/utils/log.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts +3 -0
- package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/version.d.ts +2 -0
- package/lib/typescript/commonjs/src/internals/version.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/notifyAppReady.d.ts +6 -0
- package/lib/typescript/commonjs/src/notifyAppReady.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/restartApp.d.ts +7 -0
- package/lib/typescript/commonjs/src/restartApp.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/sync.d.ts +17 -0
- package/lib/typescript/commonjs/src/sync.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types.d.ts +196 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/CodePush.d.ts +24 -0
- package/lib/typescript/module/src/CodePush.d.ts.map +1 -0
- package/lib/typescript/module/src/allowRestart.d.ts +5 -0
- package/lib/typescript/module/src/allowRestart.d.ts.map +1 -0
- package/lib/typescript/module/src/checkForUpdates.d.ts +9 -0
- package/lib/typescript/module/src/checkForUpdates.d.ts.map +1 -0
- package/lib/typescript/module/src/clearUpdates.d.ts +8 -0
- package/lib/typescript/module/src/clearUpdates.d.ts.map +1 -0
- package/lib/typescript/module/src/disallowRestart.d.ts +5 -0
- package/lib/typescript/module/src/disallowRestart.d.ts.map +1 -0
- package/lib/typescript/module/src/enums/CheckFrequency.enum.d.ts +18 -0
- package/lib/typescript/module/src/enums/CheckFrequency.enum.d.ts.map +1 -0
- package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts +14 -0
- package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts.map +1 -0
- package/lib/typescript/module/src/enums/InstallMode.enum.d.ts +27 -0
- package/lib/typescript/module/src/enums/InstallMode.enum.d.ts.map +1 -0
- package/lib/typescript/module/src/enums/SyncStatus.enum.d.ts +46 -0
- package/lib/typescript/module/src/enums/SyncStatus.enum.d.ts.map +1 -0
- package/lib/typescript/module/src/enums/UpdateState.enum.d.ts +21 -0
- package/lib/typescript/module/src/enums/UpdateState.enum.d.ts.map +1 -0
- package/lib/typescript/module/src/getUpdateMetadata.d.ts +9 -0
- package/lib/typescript/module/src/getUpdateMetadata.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +17 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts +3 -0
- package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/LocalPackageImplementation.d.ts +17 -0
- package/lib/typescript/module/src/internals/LocalPackageImplementation.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/NativeRNAppZungCodePushModule.d.ts +3 -0
- package/lib/typescript/module/src/internals/NativeRNAppZungCodePushModule.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts +36 -0
- package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts +18 -0
- package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/getConfiguration.d.ts +3 -0
- package/lib/typescript/module/src/internals/getConfiguration.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/getCurrentPackage.d.ts +2 -0
- package/lib/typescript/module/src/internals/getCurrentPackage.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts +13 -0
- package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/shouldUpdateBeIgnored.d.ts +3 -0
- package/lib/typescript/module/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/types.d.ts +16 -0
- package/lib/typescript/module/src/internals/types.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/utils/log.d.ts +2 -0
- package/lib/typescript/module/src/internals/utils/log.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts +3 -0
- package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/version.d.ts +2 -0
- package/lib/typescript/module/src/internals/version.d.ts.map +1 -0
- package/lib/typescript/module/src/notifyAppReady.d.ts +6 -0
- package/lib/typescript/module/src/notifyAppReady.d.ts.map +1 -0
- package/lib/typescript/module/src/restartApp.d.ts +7 -0
- package/lib/typescript/module/src/restartApp.d.ts.map +1 -0
- package/lib/typescript/module/src/sync.d.ts +17 -0
- package/lib/typescript/module/src/sync.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +196 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/package.json +58 -11
- package/react-native.config.js +8 -8
- package/src/CodePush.tsx +108 -0
- package/src/allowRestart.ts +6 -0
- package/src/checkForUpdates.ts +109 -0
- package/src/clearUpdates.ts +9 -0
- package/src/disallowRestart.ts +6 -0
- package/src/enums/CheckFrequency.enum.ts +19 -0
- package/src/enums/DeploymentStatus.enum.ts +14 -0
- package/src/enums/InstallMode.enum.ts +31 -0
- package/src/enums/SyncStatus.enum.ts +53 -0
- package/src/enums/UpdateState.enum.ts +24 -0
- package/src/getUpdateMetadata.ts +23 -0
- package/src/index.ts +18 -0
- package/src/internals/AcquisitionSdk.ts +3 -0
- package/src/internals/LocalPackageImplementation.ts +45 -0
- package/src/internals/NativeRNAppZungCodePushModule.ts +3 -0
- package/src/internals/RNAppZungCodePushModuleSpec.ts +54 -0
- package/src/internals/RemotePackageImplementation.ts +69 -0
- package/src/internals/getConfiguration.ts +12 -0
- package/src/internals/getCurrentPackage.ts +6 -0
- package/src/internals/getPromisifiedSdk.ts +72 -0
- package/src/internals/shouldUpdateBeIgnored.ts +76 -0
- package/src/internals/types.ts +18 -0
- package/{logging.js → src/internals/utils/log.ts} +1 -3
- package/src/internals/utils/request-fetch-adapter.ts +58 -0
- package/src/internals/version.ts +2 -0
- package/src/notifyAppReady.ts +94 -0
- package/src/reactNative.d.ts +34 -0
- package/src/restartApp.ts +10 -0
- package/src/sync.ts +272 -0
- package/src/types.ts +237 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +29 -12
- package/AlertAdapter.js +0 -24
- package/CONTRIBUTING.md +0 -134
- package/CodePush.js +0 -674
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +0 -37
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +0 -102
- package/package-mixins.js +0 -68
- package/request-fetch-adapter.js +0 -52
- package/tslint.json +0 -32
- package/typings/react-native-code-push.d.ts +0 -455
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushConstants.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushInstallMode.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushInvalidPublicKeyException.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushInvalidUpdateException.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushMalformedDataException.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushNotInitializedException.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushTelemetryManager.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushUnknownException.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushUpdateState.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushUpdateUtils.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushUtils.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/DownloadProgress.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/DownloadProgressCallback.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/FileUtils.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/ReactInstanceHolder.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/SettingsManager.java +0 -0
- /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/TLSSocketFactory.java +0 -0
package/docs/api-js.md
CHANGED
|
@@ -12,23 +12,22 @@ The following sections describe the shape and behavior of these APIs in detail:
|
|
|
12
12
|
|
|
13
13
|
When you require `react-native-code-push`, the module object provides the following top-level methods in addition to the root-level [component decorator](#codepush):
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
- [allowRestart](#codepushallowrestart): Re-allows programmatic restarts to occur as a result of an update being installed, and optionally, immediately restarts the app if a pending update had attempted to restart the app while restarts were disallowed. This is an advanced API and is only necessary if your app explicitly disallowed restarts via the `disallowRestart` method.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
- [checkForUpdate](#codepushcheckforupdate): Asks the CodePush service whether the configured app release channel has an update available.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
- [disallowRestart](#codepushdisallowrestart): Temporarily disallows any programmatic restarts to occur as a result of a CodePush update being installed. This is an advanced API, and is useful when a component within your app (for example an onboarding process) needs to ensure that no end-user interruptions can occur during its lifetime.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
- [getUpdateMetadata](#codepushgetupdatemetadata): Retrieves the metadata for an installed update (like description, mandatory).
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
- [notifyAppReady](#codepushnotifyappready): Notifies the CodePush runtime that an installed update is considered successful. If you are manually checking for and installing updates (i.e. not using the [sync](#codepushsync) method to handle it all for you), then this method **MUST** be called; otherwise CodePush will treat the update as failed and rollback to the previous version when the app next restarts.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
- [restartApp](#codepushrestartapp): Immediately restarts the app. If there is an update pending, it will be immediately displayed to the end user. Otherwise, calling this method simply has the same behavior as the end user killing and restarting the process.
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
- [sync](#codepushsync): Allows checking for an update, downloading it and installing it, all with a single call. Unless you need custom UI and/or behavior, we recommend most developers to use this method when integrating CodePush into their apps
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
_Note: we don’t recommend to use this method in scenarios other than that (CodePush will call this method automatically when needed in other cases) as it could lead to unpredictable behavior._
|
|
29
|
+
- [clearUpdates](#clearupdates): Clear all downloaded CodePush updates. This is useful when switching to a different release channel which may have an older release than the current package.
|
|
30
|
+
_Note: we don’t recommend to use this method in scenarios other than that (CodePush will call this method automatically when needed in other cases) as it could lead to unpredictable behavior._
|
|
32
31
|
|
|
33
32
|
#### codePush
|
|
34
33
|
|
|
@@ -37,6 +36,7 @@ When you require `react-native-code-push`, the module object provides the follow
|
|
|
37
36
|
codePush(rootComponent: React.Component): React.Component;
|
|
38
37
|
codePush(options: CodePushOptions)(rootComponent: React.Component): React.Component;
|
|
39
38
|
```
|
|
39
|
+
|
|
40
40
|
```javascript
|
|
41
41
|
// Decorator; Requires ES7 support
|
|
42
42
|
@codePush
|
|
@@ -47,112 +47,112 @@ Used to wrap a React component inside a "higher order" React component that know
|
|
|
47
47
|
|
|
48
48
|
This decorator provides support for letting you customize its behaviour to easily enable apps with different requirements. Below are some examples of ways you can use it (you can pick one or even use a combination):
|
|
49
49
|
|
|
50
|
-
1. **Silent sync on app start**
|
|
50
|
+
1. **Silent sync on app start** _(the simplest, default behavior)_. Your app will automatically download available updates, and apply them the next time the app restarts (like the OS or end user killed it, or the device was restarted). This way, the entire update experience is "silent" to the end user, since they don't see any update prompt and/or "synthetic" app restarts.
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
```javascript
|
|
53
|
+
// Fully silent update which keeps the app in
|
|
54
|
+
// sync with the server, without ever
|
|
55
|
+
// interrupting the end user
|
|
56
|
+
class MyApp extends Component<{}> {}
|
|
57
|
+
MyApp = codePush(MyApp);
|
|
58
|
+
export default MyApp;
|
|
59
|
+
```
|
|
60
60
|
|
|
61
61
|
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".
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
```javascript
|
|
64
|
+
// Sync for updates every time the app resumes.
|
|
65
|
+
class MyApp extends Component<{}> {}
|
|
66
|
+
MyApp = codePush({ checkFrequency: codePush.CheckFrequency.ON_APP_RESUME, installMode: codePush.InstallMode.ON_NEXT_RESUME })(MyApp);
|
|
67
|
+
export default MyApp;
|
|
68
|
+
```
|
|
69
69
|
|
|
70
70
|
3. **Interactive**. When an update is available, prompt the end user for permission before downloading it, and then immediately apply the update. If an update was released using the `mandatory` flag, the end user would still be notified about the update, but they wouldn't have the choice to ignore it.
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
```javascript
|
|
73
|
+
// Active update, which lets the end user know
|
|
74
|
+
// about each update, and displays it to them
|
|
75
|
+
// immediately after downloading it
|
|
76
|
+
class MyApp extends Component<{}> {}
|
|
77
|
+
MyApp = codePush({ updateDialog: true, installMode: codePush.InstallMode.IMMEDIATE })(MyApp);
|
|
78
|
+
export default MyApp;
|
|
79
|
+
```
|
|
80
80
|
|
|
81
81
|
4. **Log/display progress**. While the app is syncing with the server for updates, make use of the `codePushStatusDidChange` and/or `codePushDownloadDidProgress` event hooks to log down the different stages of this process, or even display a progress bar to the user.
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
83
|
+
```javascript
|
|
84
|
+
// Make use of the event hooks to keep track of
|
|
85
|
+
// the different stages of the sync process.
|
|
86
|
+
class MyApp extends Component<{}> {
|
|
87
|
+
codePushStatusDidChange(status) {
|
|
88
|
+
switch(status) {
|
|
89
|
+
case codePush.SyncStatus.CHECKING_FOR_UPDATE:
|
|
90
|
+
console.log("Checking for updates.");
|
|
91
|
+
break;
|
|
92
|
+
case codePush.SyncStatus.DOWNLOADING_PACKAGE:
|
|
93
|
+
console.log("Downloading package.");
|
|
94
|
+
break;
|
|
95
|
+
case codePush.SyncStatus.INSTALLING_UPDATE:
|
|
96
|
+
console.log("Installing update.");
|
|
97
|
+
break;
|
|
98
|
+
case codePush.SyncStatus.UP_TO_DATE:
|
|
99
|
+
console.log("Up-to-date.");
|
|
100
|
+
break;
|
|
101
|
+
case codePush.SyncStatus.UPDATE_INSTALLED:
|
|
102
|
+
console.log("Update installed.");
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
codePushDownloadDidProgress(progress) {
|
|
108
|
+
console.log(progress.receivedBytes + " of " + progress.totalBytes + " received.");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
MyApp = codePush(MyApp);
|
|
112
|
+
export default MyApp;
|
|
113
|
+
```
|
|
114
114
|
|
|
115
115
|
##### CodePushOptions
|
|
116
116
|
|
|
117
117
|
The `codePush` decorator accepts an "options" object that allows you to customize numerous aspects of the default behavior mentioned above:
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
- **checkFrequency** _(codePush.CheckFrequency)_ - Specifies when you would like to check for updates. Defaults to `codePush.CheckFrequency.ON_APP_START`. Refer to the [`CheckFrequency`](#checkfrequency) enum reference for a description of the available options and what they do.
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
- **releaseChannelPublicId** _(String)_ - Specifies the release channel public ID you want to query for an update against. By default, this value is derived from the `Info.plist` file (iOS) and strings resources (Android), but this option allows you to override it from the script-side if you need to dynamically use a different release channel.
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
- **installMode** _(codePush.InstallMode)_ - Specifies when you would like to install optional updates (i.e. those that aren't marked as mandatory). Defaults to `codePush.InstallMode.ON_NEXT_RESTART`. Refer to the [`InstallMode`](#installmode) enum reference for a description of the available options and what they do.
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
- **mandatoryInstallMode** _(codePush.InstallMode)_ - Specifies when you would like to install updates which are marked as mandatory. Defaults to `codePush.InstallMode.IMMEDIATE`. Refer to the [`InstallMode`](#installmode) enum reference for a description of the available options and what they do.
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
- **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.
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
- **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/appzung/react-native-code-push#app-store).
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
The following list represents the available options and their defaults:
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
- **appendReleaseDescription** _(Boolean)_ - Indicates whether you would like to append the description of an available release to the notification message which is displayed to the end user. Defaults to `false`.
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
- **descriptionPrefix** _(String)_ - Indicates the string you would like to prefix the release description with, if any, when displaying the update notification to the end user. Defaults to `" Description: "`
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
- **mandatoryContinueButtonLabel** _(String)_ - The text to use for the button the end user must press in order to install a mandatory update. Defaults to `"Continue"`.
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
- **mandatoryUpdateMessage** _(String)_ - The text used as the body of an update notification, when the update is specified as mandatory. Defaults to `"An update is available that must be installed."`.
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
- **optionalIgnoreButtonLabel** _(String)_ - The text to use for the button the end user can press in order to ignore an optional update that is available. Defaults to `"Ignore"`.
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
- **optionalInstallButtonLabel** _(String)_ - The text to use for the button the end user can press in order to install an optional update. Defaults to `"Install"`.
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
- **optionalUpdateMessage** _(String)_ - The text used as the body of an update notification, when the update is optional. Defaults to `"An update is available. Would you like to install it?"`.
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
- **title** _(String)_ - The text used as the header of an update notification that is displayed to the end user. Defaults to `"Update available"`.
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
- **rollbackRetryOptions** _(RollbackRetryOptions)_ - The rollback retry mechanism allows the application to attempt to reinstall an update that was previously rolled back (with the restrictions specified in the options). It is an "options" object used to determine whether a rollback retry should occur, and if so, what settings to use for the rollback retry. This defaults to null, which has the effect of disabling the retry mechanism. Setting this to any truthy value will enable the retry mechanism with the default settings, and passing an object to this parameter allows enabling the rollback retry as well as overriding one or more of the default values.
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
The following list represents the available options and their defaults:
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
- **delayInHours** _(Number)_ - Specifies the minimum time in hours that the app will wait after the latest rollback before attempting to reinstall the same rolled-back package. Defaults to `24`.
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
- **maxRetryAttempts** _(Number)_ - Specifies the maximum number of retry attempts that the app can make before it stops trying. Cannot be less than `1`. Defaults to `1`.
|
|
156
156
|
|
|
157
157
|
##### codePushStatusDidChange (event hook)
|
|
158
158
|
|
|
@@ -162,9 +162,9 @@ Called when the sync process moves from one stage to another in the overall upda
|
|
|
162
162
|
|
|
163
163
|
Called periodically when an available update is being downloaded from the CodePush server. The method is called with a `DownloadProgress` object, which contains the following two properties:
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
- **totalBytes** _(Number)_ - The total number of bytes expected to be received for this update (i.e. the size of the set of files which changed from the previous release).
|
|
166
166
|
|
|
167
|
-
|
|
167
|
+
- **receivedBytes** _(Number)_ - The number of bytes downloaded thus far, which can be used to track download progress.
|
|
168
168
|
|
|
169
169
|
#### codePush.allowRestart
|
|
170
170
|
|
|
@@ -202,31 +202,31 @@ Second optional parameter `handleBinaryVersionMismatchCallback` is an optional c
|
|
|
202
202
|
E.g. consider a use-case where currently installed binary version is 1.0.1 with label(codepush label) v1. Later native code was changed in the dev cycle and binary version was updated to 1.0.2. When code-push update check is triggered we ignore updates having binary version mismatch (because the update is not targeting to the binary version of currently installed app). In this case installed app (1.0.1) will ignore the update targeting version 1.0.2. You can use `handleBinaryVersionMismatchCallback` to provide a hook to handle such situations.
|
|
203
203
|
|
|
204
204
|
**NOTE:**
|
|
205
|
-
Be cautious to use Alerts within this callback if you are developing iOS application, due to [App Store](https://developer.apple.com/app-store/review/guidelines/) review process:
|
|
205
|
+
Be cautious to use Alerts within this callback if you are developing iOS application, due to [App Store](https://developer.apple.com/app-store/review/guidelines/) review process:
|
|
206
|
+
|
|
206
207
|
> Apps must not force users to rate the app, review the app, download other apps, or other similar actions in order to access functionality, content, or use of the app.
|
|
207
208
|
|
|
208
209
|
This method returns a `Promise` which resolves to one of two possible values:
|
|
209
210
|
|
|
210
211
|
1. `null` if there is no update available. This can occur in the following scenarios:
|
|
211
212
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
1. The configured release channel doesn't contain any releases, and therefore, nothing to update.
|
|
214
|
+
2. The latest release within the configured release channel is targeting a different binary version than what you're currently running (either older or newer).
|
|
215
|
+
3. The currently running app already has the latest release from the configured release channel, and therefore, doesn't need it again.
|
|
216
|
+
4. The latest release within the configured release channel is currently marked as disabled, and therefore, isn't allowed to be downloaded.
|
|
217
|
+
5. The latest release within the configured release channel is in an "active rollout" state, and the requesting device doesn't fall within the percentage of users who are eligible for it.
|
|
217
218
|
|
|
218
219
|
2. A [`RemotePackage`](#remotepackage) instance which represents an available update that can be inspected and/or subsequently downloaded.
|
|
219
220
|
|
|
220
221
|
Example Usage:
|
|
221
222
|
|
|
222
223
|
```javascript
|
|
223
|
-
codePush.checkForUpdate()
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
224
|
+
codePush.checkForUpdate().then((update) => {
|
|
225
|
+
if (!update) {
|
|
226
|
+
console.log('The app is up to date!');
|
|
227
|
+
} else {
|
|
228
|
+
console.log('An update is available! Should we download it?');
|
|
229
|
+
}
|
|
230
230
|
});
|
|
231
231
|
```
|
|
232
232
|
|
|
@@ -242,7 +242,7 @@ Temporarily disallows programmatic restarts to occur as a result of either of fo
|
|
|
242
242
|
2. A CodePush update is installed using `InstallMode.ON_NEXT_RESUME` and the app is resumed from the background (optionally being throttled by the `minimumBackgroundDuration` property)
|
|
243
243
|
3. The `restartApp` method was called
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
_NOTE: #1 and #2 effectively work by calling `restartApp` for you, so you can think of `disallowRestart` as blocking any call to `restartApp`, regardless if your app calls it directly or indirectly._
|
|
246
246
|
|
|
247
247
|
After calling this method, any calls to `sync` would still be allowed to check for an update, download it and install it, but an attempt to restart the app would be queued until `allowRestart` is called. This way, the restart request is captured and can be "flushed" whenever you want to allow it to occur.
|
|
248
248
|
|
|
@@ -285,13 +285,13 @@ This method returns a `Promise` which resolves to one of two possible values:
|
|
|
285
285
|
|
|
286
286
|
1. `null` if an update with the specified state doesn't currently exist. This occurs in the following scenarios:
|
|
287
287
|
|
|
288
|
-
|
|
288
|
+
1. The end-user hasn't installed any CodePush updates yet, and therefore, no metadata is available for any updates, regardless what you specify as the `updateState` parameter.
|
|
289
289
|
|
|
290
|
-
|
|
290
|
+
2. The end-user installed an update of the binary (for example from the store), which cleared away the old CodePush updates, and gave precedence back to the JS binary in the binary. Therefore, it would exhibit the same behavior as #1
|
|
291
291
|
|
|
292
|
-
|
|
292
|
+
3. The `updateState` parameter is set to `UpdateState.RUNNING`, but the app isn't currently running a CodePush update. There may be a pending update, but the app hasn't been restarted yet in order to make it active.
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
4. The `updateState` parameter is set to `UpdateState.PENDING`, but the app doesn't have any currently pending updates.
|
|
295
295
|
|
|
296
296
|
2. A [`LocalPackage`](#localpackage) instance which represents the metadata for the currently requested CodePush update (either the running or pending).
|
|
297
297
|
|
|
@@ -302,16 +302,16 @@ Example Usage:
|
|
|
302
302
|
// so, register it with the HockeyApp SDK (https://github.com/slowpath/react-native-hockeyapp)
|
|
303
303
|
// so that crash reports will correctly display the JS bundle version the user was running.
|
|
304
304
|
codePush.getUpdateMetadata().then((update) => {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
305
|
+
if (update) {
|
|
306
|
+
hockeyApp.addMetadata({ CodePushRelease: update.label });
|
|
307
|
+
}
|
|
308
308
|
});
|
|
309
309
|
|
|
310
310
|
// Check to see if there is still an update pending.
|
|
311
311
|
codePush.getUpdateMetadata(UpdateState.PENDING).then((update) => {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
312
|
+
if (update) {
|
|
313
|
+
// There's a pending update, do we want to force a restart?
|
|
314
|
+
}
|
|
315
315
|
});
|
|
316
316
|
```
|
|
317
317
|
|
|
@@ -335,7 +335,7 @@ Immediately restarts the app. If a truthy value is provided to the `onlyIfUpdate
|
|
|
335
335
|
|
|
336
336
|
This method is for advanced scenarios, and is primarily useful when the following conditions are true:
|
|
337
337
|
|
|
338
|
-
1. Your app is specifying an install mode value of `ON_NEXT_RESTART` or `ON_NEXT_RESUME` when calling the `sync` or `LocalPackage.install` methods. This has the effect of not applying your update until the app has been restarted (by either the end user or OS)
|
|
338
|
+
1. Your app is specifying an install mode value of `ON_NEXT_RESTART` or `ON_NEXT_RESUME` when calling the `sync` or `LocalPackage.install` methods. This has the effect of not applying your update until the app has been restarted (by either the end user or OS) or resumed, and therefore, the update won't be immediately displayed to the end user.
|
|
339
339
|
|
|
340
340
|
2. You have an app-specific user event (like the end user navigated back to the app's home route) that allows you to apply the update in an unobtrusive way, and potentially gets the update in front of the end user sooner then waiting until the next restart or resume.
|
|
341
341
|
|
|
@@ -349,7 +349,7 @@ Synchronizes your app's JavaScript bundle and image assets with the latest relea
|
|
|
349
349
|
|
|
350
350
|
This method provides support for two different (but customizable) "modes" to easily enable apps with different requirements:
|
|
351
351
|
|
|
352
|
-
1. **Silent mode**
|
|
352
|
+
1. **Silent mode** _(the default behavior)_, which automatically downloads available updates, and applies them the next time the app restarts (for example the OS or end user killed it, or the device was restarted). This way, the entire update experience is "silent" to the end user, since they don't see any update prompt and/or "synthetic" app restarts.
|
|
353
353
|
|
|
354
354
|
2. **Active mode**, which when an update is available, prompts the end user for permission before downloading it, and then immediately applies the update. If an update was released using the `mandatory` flag, the end user would still be notified about the update, but they wouldn't have the choice to ignore it.
|
|
355
355
|
|
|
@@ -367,21 +367,21 @@ codePush.sync();
|
|
|
367
367
|
codePush.sync({ updateDialog: true, installMode: codePush.InstallMode.IMMEDIATE });
|
|
368
368
|
```
|
|
369
369
|
|
|
370
|
-
|
|
370
|
+
_Note: If you want to decide whether you check and/or download an available update based on the end user's device battery level, network conditions, etc. then simply wrap the call to `sync` in a condition that ensures you only call it when desired._
|
|
371
371
|
|
|
372
372
|
##### SyncOptions
|
|
373
373
|
|
|
374
374
|
While the `sync` method tries to make it easy to perform silent and active updates with little configuration, it accepts an "options" object that allows you to customize numerous aspects of the default behavior mentioned above. The options available are identical to the [CodePushOptions](#codepushoptions), with the exception of the `checkFrequency` option:
|
|
375
375
|
|
|
376
|
-
|
|
376
|
+
- **releaseChannelPublicId** _(String)_ - Refer to [`CodePushOptions`](#codepushoptions).
|
|
377
377
|
|
|
378
|
-
|
|
378
|
+
- **installMode** _(codePush.InstallMode)_ - Refer to [`CodePushOptions`](#codepushoptions).
|
|
379
379
|
|
|
380
|
-
|
|
380
|
+
- **mandatoryInstallMode** _(codePush.InstallMode)_ - Refer to [`CodePushOptions`](#codepushoptions).
|
|
381
381
|
|
|
382
|
-
|
|
382
|
+
- **minimumBackgroundDuration** _(Number)_ - Refer to [`CodePushOptions`](#codepushoptions).
|
|
383
383
|
|
|
384
|
-
|
|
384
|
+
- **updateDialog** _(UpdateDialogOptions)_ - Refer to [`CodePushOptions`](#codepushoptions).
|
|
385
385
|
|
|
386
386
|
Example Usage:
|
|
387
387
|
|
|
@@ -389,7 +389,7 @@ Example Usage:
|
|
|
389
389
|
// Use a different release channel public ID for this
|
|
390
390
|
// specific call, instead of the one configured
|
|
391
391
|
// in the Info.plist file
|
|
392
|
-
codePush.sync({ releaseChannelPublicId:
|
|
392
|
+
codePush.sync({ releaseChannelPublicId: 'KEY' });
|
|
393
393
|
|
|
394
394
|
// Download the update silently, but install it on
|
|
395
395
|
// the next resume, as long as at least 5 minutes
|
|
@@ -402,63 +402,64 @@ codePush.sync({ mandatoryInstallMode: codePush.InstallMode.ON_NEXT_RESUME });
|
|
|
402
402
|
|
|
403
403
|
// Changing the title displayed in the
|
|
404
404
|
// confirmation dialog of an "active" update
|
|
405
|
-
codePush.sync({ updateDialog: { title:
|
|
405
|
+
codePush.sync({ updateDialog: { title: 'An update is available!' } });
|
|
406
406
|
|
|
407
407
|
// Displaying an update prompt which includes the
|
|
408
408
|
// description associated with the CodePush release
|
|
409
409
|
codePush.sync({
|
|
410
|
-
|
|
410
|
+
updateDialog: {
|
|
411
411
|
appendReleaseDescription: true,
|
|
412
|
-
descriptionPrefix:
|
|
413
|
-
|
|
414
|
-
|
|
412
|
+
descriptionPrefix: '\n\nChange log:\n',
|
|
413
|
+
},
|
|
414
|
+
installMode: codePush.InstallMode.IMMEDIATE,
|
|
415
415
|
});
|
|
416
416
|
```
|
|
417
417
|
|
|
418
418
|
In addition to the options, the `sync` method also accepts several optional function parameters which allow you to subscribe to the lifecycle of the `sync` "pipeline" in order to display additional UI as needed (like a "checking for update modal or a download progress modal):
|
|
419
419
|
|
|
420
|
-
|
|
420
|
+
- **syncStatusChangedCallback** _((syncStatus: Number) => void)_ - Called when the sync process moves from one stage to another in the overall update process. The method is called with a status code which represents the current state, and can be any of the [`SyncStatus`](#syncstatus) values.
|
|
421
421
|
|
|
422
|
-
|
|
422
|
+
- **downloadProgressCallback** _((progress: DownloadProgress) => void)_ - Called periodically when an available update is being downloaded from the CodePush server. The method is called with a `DownloadProgress` object, which contains the following two properties:
|
|
423
423
|
|
|
424
|
-
|
|
424
|
+
- **totalBytes** _(Number)_ - The total number of bytes expected to be received for this update (i.e. the size of the set of files which changed from the previous release).
|
|
425
425
|
|
|
426
|
-
|
|
426
|
+
- **receivedBytes** _(Number)_ - The number of bytes downloaded thus far, which can be used to track download progress.
|
|
427
427
|
|
|
428
|
-
|
|
429
|
-
Called when there are any binary update available. The method is called with a [`RemotePackage`](#remotepackage) object. Refer to [codePush.checkForUpdate](#codepushcheckforupdate) section for more details.
|
|
428
|
+
- **handleBinaryVersionMismatchCallback** _((update: RemotePackage) => void)_ -
|
|
429
|
+
Called when there are any binary update available. The method is called with a [`RemotePackage`](#remotepackage) object. Refer to [codePush.checkForUpdate](#codepushcheckforupdate) section for more details.
|
|
430
430
|
|
|
431
431
|
Example Usage:
|
|
432
432
|
|
|
433
433
|
```javascript
|
|
434
434
|
// Prompt the user when an update is available
|
|
435
435
|
// and then display a "downloading" modal
|
|
436
|
-
codePush.sync(
|
|
436
|
+
codePush.sync(
|
|
437
|
+
{ updateDialog: true },
|
|
437
438
|
(status) => {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
439
|
+
switch (status) {
|
|
440
|
+
case codePush.SyncStatus.DOWNLOADING_PACKAGE:
|
|
441
|
+
// Show "downloading" modal
|
|
442
|
+
break;
|
|
443
|
+
case codePush.SyncStatus.INSTALLING_UPDATE:
|
|
444
|
+
// Hide "downloading" modal
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
446
447
|
},
|
|
447
|
-
({ receivedBytes, totalBytes
|
|
448
|
+
({ receivedBytes, totalBytes }) => {
|
|
448
449
|
/* Update download modal progress */
|
|
449
|
-
}
|
|
450
|
+
},
|
|
450
451
|
);
|
|
451
452
|
```
|
|
452
453
|
|
|
453
454
|
This method returns a `Promise` which is resolved to a `SyncStatus` code that indicates why the `sync` call succeeded. This code can be one of the following `SyncStatus` values:
|
|
454
455
|
|
|
455
|
-
|
|
456
|
+
- **codePush.SyncStatus.UP_TO_DATE** _(0)_ - The app is up-to-date with the CodePush server.
|
|
456
457
|
|
|
457
|
-
|
|
458
|
+
- **codePush.SyncStatus.UPDATE_IGNORED** _(2)_ - The app had an optional update which the end user chose to ignore. (This is only applicable when the `updateDialog` is used)
|
|
458
459
|
|
|
459
|
-
|
|
460
|
+
- **codePush.SyncStatus.UPDATE_INSTALLED** _(1)_ - The update has been installed and will be run either immediately after the `syncStatusChangedCallback` function returns or the next time the app resumes/restarts, depending on the `InstallMode` specified in `SyncOptions`.
|
|
460
461
|
|
|
461
|
-
|
|
462
|
+
- **codePush.SyncStatus.SYNC_IN_PROGRESS** _(4)_ - There is an ongoing `sync` operation running which prevents the current call from being executed.
|
|
462
463
|
|
|
463
464
|
The `sync` method can be called anywhere you'd like to check for an update. That could be in the `componentWillMount` lifecycle event of your root component, the onPress handler of a `<TouchableHighlight>` component, in the callback of a periodic timer, or whatever else makes sense for your needs. Just like the `checkForUpdate` method, it will perform the network request to check for an update in the background, so it won't impact your UI thread and/or JavaScript thread's responsiveness.
|
|
464
465
|
|
|
@@ -466,29 +467,30 @@ The `sync` method can be called anywhere you'd like to check for an update. That
|
|
|
466
467
|
|
|
467
468
|
The `checkForUpdate` and `getUpdateMetadata` methods return `Promise` objects, that when resolved, provide acces to "package" objects. The package represents your code update as well as any extra metadata (like description, mandatory?). The CodePush API has the distinction between the following types of packages:
|
|
468
469
|
|
|
469
|
-
|
|
470
|
+
- [LocalPackage](#localpackage): Represents a downloaded update that is either already running, or has been installed and is pending an app restart.
|
|
470
471
|
|
|
471
|
-
|
|
472
|
+
- [RemotePackage](#remotepackage): Represents an available update on the CodePush server that hasn't been downloaded yet.
|
|
472
473
|
|
|
473
474
|
##### LocalPackage
|
|
474
475
|
|
|
475
476
|
Contains details about an update that has been downloaded locally or already installed. You can get a reference to an instance of this object either by calling the module-level `getUpdateMetadata` method, or as the value of the promise returned by the `RemotePackage.download` method.
|
|
476
477
|
|
|
477
478
|
###### Properties
|
|
478
|
-
|
|
479
|
-
-
|
|
480
|
-
-
|
|
481
|
-
-
|
|
482
|
-
-
|
|
483
|
-
-
|
|
484
|
-
-
|
|
485
|
-
-
|
|
486
|
-
-
|
|
487
|
-
-
|
|
479
|
+
|
|
480
|
+
- **appVersion**: The app binary version that this update is dependent on. This is the value that was specified via the `appStoreVersion` parameter when calling the CLI's `release` command. _(String)_
|
|
481
|
+
- **releaseChannelPublicId**: The release channel that was used to originally download this update. _(String)_
|
|
482
|
+
- **description**: The description of the update. This is the same value that you specified in the CLI when you released the update. _(String)_
|
|
483
|
+
- **failedInstall**: Indicates whether this update has been previously installed but was rolled back. The `sync` method will automatically ignore updates which have previously failed, so you only need to worry about this property if using `checkForUpdate`. _(Boolean)_
|
|
484
|
+
- **isFirstRun**: Indicates whether this is the first time the update has been run after being installed. This is useful for determining whether you would like to show a "What's New?" UI to the end user after installing an update. _(Boolean)_
|
|
485
|
+
- **isMandatory**: Indicates whether the update is considered mandatory. This is the value that was specified in the CLI when the update was released. _(Boolean)_
|
|
486
|
+
- **isPending**: Indicates whether this update is in a "pending" state. When `true`, that means the update has been downloaded and installed, but the app restart needed to apply it hasn't occurred yet, and therefore, it's changes aren't currently visible to the end-user. _(Boolean)_
|
|
487
|
+
- **label**: The internal label automatically given to the update by the CodePush server, such as `v5`. This value uniquely identifies the update within its release channel. _(String)_
|
|
488
|
+
- **packageHash**: The SHA hash value of the update. _(String)_
|
|
489
|
+
- **packageSize**: The size of the code contained within the update, in bytes. _(Number)_
|
|
488
490
|
|
|
489
491
|
###### Methods
|
|
490
492
|
|
|
491
|
-
-
|
|
493
|
+
- **install(installMode: codePush.InstallMode = codePush.InstallMode.ON_NEXT_RESTART, minimumBackgroundDuration = 0): Promise<void>**: Installs the update by saving it to the location on disk where the runtime expects to find the latest version of the app. The `installMode` parameter controls when the changes are actually presented to the end user. The default value is to wait until the next app restart to display the changes, but you can refer to the [`InstallMode`](#installmode) enum reference for a description of the available options and what they do. If the `installMode` parameter is set to `InstallMode.ON_NEXT_RESUME`, then the `minimumBackgroundDuration` parameter allows you to control how long the app must have been in the background before forcing the install after it is resumed.
|
|
492
494
|
|
|
493
495
|
##### RemotePackage
|
|
494
496
|
|
|
@@ -498,11 +500,11 @@ Contains details about an update that is available for download from the CodePus
|
|
|
498
500
|
|
|
499
501
|
The `RemotePackage` inherits all of the same properties as the `LocalPackage`, but includes one additional one:
|
|
500
502
|
|
|
501
|
-
-
|
|
503
|
+
- **downloadUrl**: The URL at which the package is available for download. This property is only needed for advanced usage, since the `download` method will automatically handle the acquisition of updates for you. _(String)_
|
|
502
504
|
|
|
503
505
|
###### Methods
|
|
504
506
|
|
|
505
|
-
-
|
|
507
|
+
- **download(downloadProgressCallback?: Function): Promise<LocalPackage>**: Downloads the available update from the CodePush service. If a `downloadProgressCallback` is specified, it will be called periodically with a `DownloadProgress` object (`{ totalBytes: Number, receivedBytes: Number }`) that reports the progress of the download until it completes. Returns a Promise that resolves with the `LocalPackage`.
|
|
506
508
|
|
|
507
509
|
#### Enums
|
|
508
510
|
|
|
@@ -512,44 +514,44 @@ The CodePush API includes the following enums which can be used to customize the
|
|
|
512
514
|
|
|
513
515
|
This enum specifies when you would like an installed update to actually be applied, and can be passed to either the `sync` or `LocalPackage.install` methods. It includes the following values:
|
|
514
516
|
|
|
515
|
-
|
|
517
|
+
- **codePush.InstallMode.IMMEDIATE** _(0)_ - Indicates that you want to install the update and restart the app immediately. This value is appropriate for debugging scenarios as well as when displaying an update prompt to the user, since they would expect to see the changes immediately after accepting the installation. Additionally, this mode can be used to enforce mandatory updates, since it removes the potentially undesired latency between the update installation and the next time the end user restarts or resumes the app.
|
|
516
518
|
|
|
517
|
-
|
|
519
|
+
- **codePush.InstallMode.ON_NEXT_RESTART** _(1)_ - Indicates that you want to install the update, but not forcibly restart the app. When the app is "naturally" restarted (due the OS or end user killing it), the update will be seamlessly picked up. This value is appropriate when performing silent updates, since it would likely be disruptive to the end user if the app suddenly restarted out of nowhere, since they wouldn't have realized an update was even downloaded. This is the default mode used for both the `sync` and `LocalPackage.install` methods.
|
|
518
520
|
|
|
519
|
-
|
|
521
|
+
- **codePush.InstallMode.ON_NEXT_RESUME** _(2)_ - Indicates that you want to install the update, but don't want to restart the app until the next time the end user resumes it from the background. This way, you don't disrupt their current session, but you can get the update in front of them sooner then having to wait for the next natural restart. This value is appropriate for silent installs that can be applied on resume in a non-invasive way.
|
|
520
522
|
|
|
521
|
-
|
|
523
|
+
- **codePush.InstallMode.ON_NEXT_SUSPEND** _(3)_ - Indicates that you want to install the update _while_ it is in the background, but only after it has been in the background for `minimumBackgroundDuration` seconds (0 by default), so that user context isn't lost unless the app suspension is long enough to not matter.
|
|
522
524
|
|
|
523
525
|
##### CheckFrequency
|
|
524
526
|
|
|
525
527
|
This enum specifies when you would like your app to sync with the server for updates, and can be passed to the `codePushify` decorator. It includes the following values:
|
|
526
528
|
|
|
527
|
-
|
|
529
|
+
- **codePush.CheckFrequency.ON_APP_START** _(0)_ - Indicates that you want to check for updates whenever the app's process is started.
|
|
528
530
|
|
|
529
|
-
|
|
531
|
+
- **codePush.CheckFrequency.ON_APP_RESUME** _(1)_ - Indicates that you want to check for updates whenever the app is brought back to the foreground after being "backgrounded" (user pressed the home button, app launches a seperate payment process, etc).
|
|
530
532
|
|
|
531
|
-
|
|
533
|
+
- **codePush.CheckFrequency.MANUAL** _(2)_ - Disable automatic checking for updates, but only check when [`codePush.sync()`](#codepushsync) is called in app code.
|
|
532
534
|
|
|
533
535
|
##### SyncStatus
|
|
534
536
|
|
|
535
537
|
This enum is provided to the `syncStatusChangedCallback` function that can be passed to the `sync` method, in order to hook into the overall update process. It includes the following values:
|
|
536
538
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
539
|
+
- **codePush.SyncStatus.UP_TO_DATE** _(0)_ - The app is fully up-to-date with the configured release channel.
|
|
540
|
+
- **codePush.SyncStatus.UPDATE_INSTALLED** _(1)_ - An available update has been installed and will be run either immediately after the `syncStatusChangedCallback` function returns or the next time the app resumes/restarts, depending on the `InstallMode` specified in `SyncOptions`.
|
|
541
|
+
- **codePush.SyncStatus.UPDATE_IGNORED** _(2)_ - The app has an optional update, which the end user chose to ignore. (This is only applicable when the `updateDialog` is used)
|
|
542
|
+
- **codePush.SyncStatus.UNKNOWN_ERROR** _(3)_ - The sync operation encountered an unknown error.
|
|
543
|
+
- **codePush.SyncStatus.SYNC_IN_PROGRESS** _(4)_ - There is an ongoing `sync` operation running which prevents the current call from being executed.
|
|
544
|
+
- **codePush.SyncStatus.CHECKING_FOR_UPDATE** _(5)_ - The CodePush server is being queried for an update.
|
|
545
|
+
- **codePush.SyncStatus.AWAITING_USER_ACTION** _(6)_ - An update is available, and a confirmation dialog was shown to the end user. (This is only applicable when the `updateDialog` is used)
|
|
546
|
+
- **codePush.SyncStatus.DOWNLOADING_PACKAGE** _(7)_ - An available update is being downloaded from the CodePush server.
|
|
547
|
+
- **codePush.SyncStatus.INSTALLING_UPDATE** _(8)_ - An available update was downloaded and is about to be installed.
|
|
546
548
|
|
|
547
549
|
##### UpdateState
|
|
548
550
|
|
|
549
551
|
This enum specifies the state that an update is currently in, and can be specified when calling the `getUpdateMetadata` method. It includes the following values:
|
|
550
552
|
|
|
551
|
-
|
|
553
|
+
- **codePush.UpdateState.RUNNING** _(0)_ - Indicates that an update represents the version of the app that is currently running. This can be useful for identifying attributes about the app, for scenarios such as displaying the release description in a "what's new?" dialog or reporting the latest version to an analytics and/or crash reporting service.
|
|
552
554
|
|
|
553
|
-
|
|
555
|
+
- **codePush.UpdateState.PENDING** _(1)_ - Indicates than an update has been installed, but the app hasn't been restarted yet in order to apply it. This can be useful for determining whether there is a pending update, which you may want to force a programmatic restart (via `restartApp`) in order to apply.
|
|
554
556
|
|
|
555
|
-
|
|
557
|
+
- **codePush.UpdateState.LATEST** _(2)_ - Indicates than an update represents the latest available release, and can be either currently running or pending.
|