mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-16 19:51:57 +08:00
Expose clearUpdates method to RN for purging downloaded packages (#1269)
This is useful when changing to a deployment with an older version than the currently installed package.
This commit is contained in:
@@ -542,6 +542,7 @@ if (NativeCodePush) {
|
||||
sync,
|
||||
disallowRestart: RestartManager.disallow,
|
||||
allowRestart: RestartManager.allow,
|
||||
clearUpdates: NativeCodePush.clearUpdates,
|
||||
InstallMode: {
|
||||
IMMEDIATE: NativeCodePush.codePushInstallModeImmediate, // Restart the app immediately
|
||||
ON_NEXT_RESTART: NativeCodePush.codePushInstallModeOnNextRestart, // Don't artificially restart the app. Allow the update to be "picked up" on the next app restart
|
||||
|
||||
@@ -587,4 +587,9 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
||||
CodePushUtils.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void clearUpdates() {
|
||||
mCodePush.clearUpdates();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ When you require `react-native-code-push`, the module object provides the follow
|
||||
|
||||
* [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
|
||||
|
||||
* [clearUpdates](#clearupdates): Clear all downloaded CodePush updates. This is useful when switching to a different deployment which may have an older release than the current package.
|
||||
|
||||
#### codePush
|
||||
|
||||
```javascript
|
||||
|
||||
@@ -209,8 +209,6 @@ static NSString *bundleResourceSubdirectory = nil;
|
||||
[CodePushConfig current].deploymentKey = deploymentKey;
|
||||
}
|
||||
|
||||
#pragma mark - Test-only methods
|
||||
|
||||
/*
|
||||
* WARNING: This cleans up all downloaded and pending updates.
|
||||
*/
|
||||
@@ -221,6 +219,8 @@ static NSString *bundleResourceSubdirectory = nil;
|
||||
[self removeFailedUpdates];
|
||||
}
|
||||
|
||||
#pragma mark - Test-only methods
|
||||
|
||||
/*
|
||||
* This returns a boolean value indicating whether CodePush has
|
||||
* been set to run under a test configuration.
|
||||
@@ -867,6 +867,14 @@ RCT_EXPORT_METHOD(restartApp:(BOOL)onlyIfUpdateIsPending
|
||||
resolve(@(NO));
|
||||
}
|
||||
|
||||
/*
|
||||
* This method clears CodePush's downloaded updates.
|
||||
* It is needed to switch to a different deployment if the current deployment is more recent.
|
||||
*/
|
||||
RCT_EXPORT_METHOD(clearUpdates) {
|
||||
[CodePush clearUpdates];
|
||||
}
|
||||
|
||||
#pragma mark - JavaScript-exported module methods (Private)
|
||||
|
||||
/*
|
||||
|
||||
6
typings/react-native-code-push.d.ts
vendored
6
typings/react-native-code-push.d.ts
vendored
@@ -273,6 +273,12 @@ declare namespace CodePush {
|
||||
*/
|
||||
function disallowRestart(): void;
|
||||
|
||||
/**
|
||||
* Clear all downloaded CodePush updates.
|
||||
* This is useful when switching to a different deployment which may have an older release than the current package.
|
||||
*/
|
||||
function clearUpdates(): void;
|
||||
|
||||
/**
|
||||
* Immediately restarts the app.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user