mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-10 15:49:36 +08:00
Android implementation
This commit is contained in:
@@ -339,7 +339,7 @@ If you are using the `sync` function, and doing your update check on app start,
|
||||
codePush.restartApp(onlyIfUpdateIsPending: Boolean = false): void;
|
||||
```
|
||||
|
||||
Immediately restarts the app. If there is an update pending, it will be presented to the end user and the rollback timer (if specified when installing the update) will begin. Otherwise, calling this method simply has the same behavior as the end user killing and restarting the process. If a truthy value is passed to the `onlyIfUpdateIsPending` parameter, then the app will only be restarted if there is actually a pending update waiting to be applied. Otherwise, this method call will no-op.
|
||||
Immediately restarts the app. If there is an update pending, it will be presented to the end user and the "rollback protection" feature will ensure it succeeds. Otherwise, calling this method simply has the same behavior as the end user killing and restarting the process. If a truthy value is passed to the `onlyIfUpdateIsPending` parameter, then the app will only be restarted if there is actually a pending update waiting to be applied. Otherwise, this method call will no-op.
|
||||
|
||||
This method is for advanced scenarios, and is primarily useful when the following conditions are true:
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ public class CodePush {
|
||||
try {
|
||||
boolean updateIsPending = pendingUpdate != null &&
|
||||
pendingUpdate.getBoolean(PENDING_UPDATE_IS_LOADING_KEY) == false &&
|
||||
pendingUpdate.getString(PENDING_UPDATE_HASH_KEY).equals(packageHash);
|
||||
(packageHash == null || pendingUpdate.getString(PENDING_UPDATE_HASH_KEY).equals(packageHash));
|
||||
return updateIsPending;
|
||||
}
|
||||
catch (JSONException e) {
|
||||
@@ -483,8 +483,12 @@ public class CodePush {
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void restartApp() {
|
||||
loadBundle();
|
||||
public void restartApp(boolean onlyIfUpdateIsPending) {
|
||||
// If this is an unconditional restart request, or there
|
||||
// is current pending update, then reload the app.
|
||||
if (!onlyIfUpdateIsPending || CodePush.this.isPendingUpdate(null)) {
|
||||
loadBundle();
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
|
||||
Reference in New Issue
Block a user