mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-05-19 19:39:54 +08:00
* Handle TargetBinaryVersionMismatch * fix readme, add binary version mismatch example to docs * fix docs, typings
This commit is contained in:
committed by
Sergey Akhalkov
parent
26d84b5a81
commit
85e094f7e1
@@ -179,11 +179,18 @@ See [disallowRestart](#codepushdisallowrestart) for an example of how this metho
|
||||
#### codePush.checkForUpdate
|
||||
|
||||
```javascript
|
||||
codePush.checkForUpdate(deploymentKey: String = null): Promise<RemotePackage>;
|
||||
codePush.checkForUpdate(deploymentKey: String = null, handleBinaryVersionMismatchCallback: (update: RemotePackage) => void): Promise<RemotePackage>;
|
||||
```
|
||||
|
||||
Queries the CodePush service to see whether the configured app deployment has an update available. By default, it will use the deployment key that is configured in your `Info.plist` file (iOS), or `MainActivity.java` file (Android), but you can override that by specifying a value via the optional `deploymentKey` parameter. This can be useful when you want to dynamically "redirect" a user to a specific deployment, such as allowing "early access" via an easter egg or a user setting switch.
|
||||
|
||||
Second optional parameter `handleBinaryVersionMismatchCallback` is an optional callback function that can be used to notify user if there are any binary update.
|
||||
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.
|
||||
|
||||
**NOTE:**
|
||||
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:
|
||||
> 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.
|
||||
|
||||
This method returns a `Promise` which resolves to one of two possible values:
|
||||
|
||||
1. `null` if there is no update available. This can occur in the following scenarios:
|
||||
@@ -356,7 +363,7 @@ This method is for advanced scenarios, and is primarily useful when the followin
|
||||
#### codePush.sync
|
||||
|
||||
```javascript
|
||||
codePush.sync(options: Object, syncStatusChangeCallback: function(syncStatus: Number), downloadProgressCallback: function(progress: DownloadProgress)): Promise<Number>;
|
||||
codePush.sync(options: Object, syncStatusChangeCallback: function(syncStatus: Number), downloadProgressCallback: function(progress: DownloadProgress), handleBinaryVersionMismatchCallback: function(update: RemotePackage)): Promise<Number>;
|
||||
```
|
||||
|
||||
Synchronizes your app's JavaScript bundle and image assets with the latest release to the configured deployment. Unlike the [checkForUpdate](#codepushcheckforupdate) method, which simply checks for the presence of an update, and let's you control what to do next, `sync` handles the update check, download and installation experience for you.
|
||||
@@ -429,7 +436,7 @@ codePush.sync({
|
||||
});
|
||||
```
|
||||
|
||||
In addition to the options, the `sync` method also accepts two optional function parameters which allow you to subscribe to the lifecycle of the `sync` "pipeline" in order to display additional UI as needed (e.g. a "checking for update modal or a download progress modal):
|
||||
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 (e.g. a "checking for update modal or a download progress modal):
|
||||
|
||||
* __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.
|
||||
|
||||
@@ -439,6 +446,9 @@ In addition to the options, the `sync` method also accepts two optional function
|
||||
|
||||
* __receivedBytes__ *(Number)* - The number of bytes downloaded thus far, which can be used to track download progress.
|
||||
|
||||
* __handleBinaryVersionMismatchCallback__ *((update: RemotePackage) => void)* -
|
||||
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.
|
||||
|
||||
Example Usage:
|
||||
|
||||
```javascript
|
||||
|
||||
Reference in New Issue
Block a user