mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-12-18 11:45:07 +08:00
Back compatibility
This commit is contained in:
@@ -34,6 +34,7 @@ import static android.support.v4.content.FileProvider.getUriForFile;
|
|||||||
public class UpdateModule extends ReactContextBaseJavaModule {
|
public class UpdateModule extends ReactContextBaseJavaModule {
|
||||||
UpdateContext updateContext;
|
UpdateContext updateContext;
|
||||||
public static ReactApplicationContext mContext;
|
public static ReactApplicationContext mContext;
|
||||||
|
|
||||||
public UpdateModule(ReactApplicationContext reactContext, UpdateContext updateContext) {
|
public UpdateModule(ReactApplicationContext reactContext, UpdateContext updateContext) {
|
||||||
super(reactContext);
|
super(reactContext);
|
||||||
this.updateContext = updateContext;
|
this.updateContext = updateContext;
|
||||||
@@ -139,6 +140,9 @@ public class UpdateModule extends ReactContextBaseJavaModule{
|
|||||||
public void downloadPatchFromPackage(ReadableMap options, final Promise promise) {
|
public void downloadPatchFromPackage(ReadableMap options, final Promise promise) {
|
||||||
String url = options.getString("updateUrl");
|
String url = options.getString("updateUrl");
|
||||||
String hash = options.getString("hash");
|
String hash = options.getString("hash");
|
||||||
|
if (hash == null) {
|
||||||
|
hash = options.getString("hashName");
|
||||||
|
}
|
||||||
updateContext.downloadPatchFromApk(url, hash, new UpdateContext.DownloadFileListener() {
|
updateContext.downloadPatchFromApk(url, hash, new UpdateContext.DownloadFileListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadCompleted(DownloadTaskParams params) {
|
public void onDownloadCompleted(DownloadTaskParams params) {
|
||||||
@@ -156,7 +160,13 @@ public class UpdateModule extends ReactContextBaseJavaModule{
|
|||||||
public void downloadPatchFromPpk(ReadableMap options, final Promise promise) {
|
public void downloadPatchFromPpk(ReadableMap options, final Promise promise) {
|
||||||
String url = options.getString("updateUrl");
|
String url = options.getString("updateUrl");
|
||||||
String hash = options.getString("hash");
|
String hash = options.getString("hash");
|
||||||
|
if (hash == null) {
|
||||||
|
hash = options.getString("hashName");
|
||||||
|
}
|
||||||
String originHash = options.getString("originHash");
|
String originHash = options.getString("originHash");
|
||||||
|
if (originHash == null) {
|
||||||
|
originHash = options.getString(("originHashName"));
|
||||||
|
}
|
||||||
updateContext.downloadPatchFromPpk(url, hash, originHash, new UpdateContext.DownloadFileListener() {
|
updateContext.downloadPatchFromPpk(url, hash, originHash, new UpdateContext.DownloadFileListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadCompleted(DownloadTaskParams params) {
|
public void onDownloadCompleted(DownloadTaskParams params) {
|
||||||
@@ -172,7 +182,8 @@ public class UpdateModule extends ReactContextBaseJavaModule{
|
|||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void reloadUpdate(ReadableMap options) {
|
public void reloadUpdate(ReadableMap options) {
|
||||||
final String hash = options.getString("hash");
|
final String hash = options.getString("hash") == null ?
|
||||||
|
options.getString("hashName") : options.getString("hash");
|
||||||
|
|
||||||
UiThreadUtil.runOnUiThread(new Runnable() {
|
UiThreadUtil.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -213,7 +224,8 @@ public class UpdateModule extends ReactContextBaseJavaModule{
|
|||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void setNeedUpdate(ReadableMap options) {
|
public void setNeedUpdate(ReadableMap options) {
|
||||||
final String hash = options.getString("hash");
|
final String hash = options.getString("hash") == null ?
|
||||||
|
options.getString("hashName") : options.getString("hash");
|
||||||
|
|
||||||
UiThreadUtil.runOnUiThread(new Runnable() {
|
UiThreadUtil.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -256,6 +256,9 @@ RCT_EXPORT_METHOD(downloadPatchFromPpk:(NSDictionary *)options
|
|||||||
RCT_EXPORT_METHOD(setNeedUpdate:(NSDictionary *)options)
|
RCT_EXPORT_METHOD(setNeedUpdate:(NSDictionary *)options)
|
||||||
{
|
{
|
||||||
NSString *hash = options[@"hash"];
|
NSString *hash = options[@"hash"];
|
||||||
|
if (hash.length <= 0) {
|
||||||
|
hash = options[@"hashName"];
|
||||||
|
}
|
||||||
if (hash.length) {
|
if (hash.length) {
|
||||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||||
NSString *lastVersion = nil;
|
NSString *lastVersion = nil;
|
||||||
@@ -279,6 +282,9 @@ RCT_EXPORT_METHOD(setNeedUpdate:(NSDictionary *)options)
|
|||||||
RCT_EXPORT_METHOD(reloadUpdate:(NSDictionary *)options)
|
RCT_EXPORT_METHOD(reloadUpdate:(NSDictionary *)options)
|
||||||
{
|
{
|
||||||
NSString *hash = options[@"hash"];
|
NSString *hash = options[@"hash"];
|
||||||
|
if (hash.length <= 0) {
|
||||||
|
hash = options[@"hashName"];
|
||||||
|
}
|
||||||
if (hash.length) {
|
if (hash.length) {
|
||||||
[self setNeedUpdate:options];
|
[self setNeedUpdate:options];
|
||||||
|
|
||||||
@@ -335,6 +341,9 @@ RCT_EXPORT_METHOD(markSuccess)
|
|||||||
{
|
{
|
||||||
NSString *updateUrl = [RCTConvert NSString:options[@"updateUrl"]];
|
NSString *updateUrl = [RCTConvert NSString:options[@"updateUrl"]];
|
||||||
NSString *hash = [RCTConvert NSString:options[@"hash"]];
|
NSString *hash = [RCTConvert NSString:options[@"hash"]];
|
||||||
|
if (hash.length <= 0) {
|
||||||
|
hash = [RCTConvert NSString:options[@"hashName"]];;
|
||||||
|
}
|
||||||
if (updateUrl.length <= 0 || hash.length <= 0) {
|
if (updateUrl.length <= 0 || hash.length <= 0) {
|
||||||
callback([self errorWithMessage:ERROR_OPTIONS]);
|
callback([self errorWithMessage:ERROR_OPTIONS]);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user