Android implementation

This commit is contained in:
Jonathan Carter
2015-12-27 00:25:28 -08:00
parent fda496313c
commit 57390ef020
2 changed files with 8 additions and 4 deletions

View File

@@ -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:

View File

@@ -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