mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-10 23:59:42 +08:00
Renaming restartPendingUpdate to restartApp
This commit is contained in:
@@ -376,37 +376,10 @@ public class CodePush {
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void restartImmediateUpdate(int rollbackTimeout) {
|
||||
public void restartApp() {
|
||||
loadBundle();
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void restartPendingUpdate() {
|
||||
SharedPreferences settings = applicationContext.getSharedPreferences(CODE_PUSH_PREFERENCES, 0);
|
||||
String pendingUpdateString = settings.getString(PENDING_UPDATE_KEY, null);
|
||||
|
||||
if (pendingUpdateString != null) {
|
||||
try {
|
||||
JSONObject pendingUpdateJSON = new JSONObject(pendingUpdateString);
|
||||
String pendingHash = pendingUpdateJSON.getString(PENDING_UPDATE_HASH_KEY);
|
||||
String currentHash = codePushPackage.getCurrentPackageHash();
|
||||
if (!pendingHash.equals(currentHash)) {
|
||||
throw new CodePushUnknownException("Pending hash " + pendingHash +
|
||||
" and current hash " + currentHash + " are different");
|
||||
}
|
||||
|
||||
loadBundle();
|
||||
} catch (JSONException e) {
|
||||
// Should not happen.
|
||||
throw new CodePushUnknownException("Unable to parse pending update metadata " +
|
||||
pendingUpdateString + " stored in SharedPreferences", e);
|
||||
} catch (IOException e) {
|
||||
// There is no current package hash.
|
||||
throw new CodePushUnknownException("Should not register a pending update without a saving a current package", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getConstants() {
|
||||
final Map<String, Object> constants = new HashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user