mirror of
				https://gitcode.com/gh_mirrors/re/react-native-pushy.git
				synced 2025-10-31 13:23:12 +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 { | ||||
|     UpdateContext updateContext; | ||||
|     public static ReactApplicationContext mContext; | ||||
|  | ||||
|     public UpdateModule(ReactApplicationContext reactContext, UpdateContext updateContext) { | ||||
|         super(reactContext); | ||||
|         this.updateContext = updateContext; | ||||
| @@ -139,6 +140,9 @@ public class UpdateModule extends ReactContextBaseJavaModule{ | ||||
|     public void downloadPatchFromPackage(ReadableMap options, final Promise promise) { | ||||
|         String url = options.getString("updateUrl"); | ||||
|         String hash = options.getString("hash"); | ||||
|         if (hash == null) { | ||||
|             hash = options.getString("hashName"); | ||||
|         } | ||||
|         updateContext.downloadPatchFromApk(url, hash, new UpdateContext.DownloadFileListener() { | ||||
|             @Override | ||||
|             public void onDownloadCompleted(DownloadTaskParams params) { | ||||
| @@ -156,7 +160,13 @@ public class UpdateModule extends ReactContextBaseJavaModule{ | ||||
|     public void downloadPatchFromPpk(ReadableMap options, final Promise promise) { | ||||
|         String url = options.getString("updateUrl"); | ||||
|         String hash = options.getString("hash"); | ||||
|         if (hash == null) { | ||||
|             hash = options.getString("hashName"); | ||||
|         } | ||||
|         String originHash = options.getString("originHash"); | ||||
|         if (originHash == null) { | ||||
|             originHash = options.getString(("originHashName")); | ||||
|         } | ||||
|         updateContext.downloadPatchFromPpk(url, hash, originHash, new UpdateContext.DownloadFileListener() { | ||||
|             @Override | ||||
|             public void onDownloadCompleted(DownloadTaskParams params) { | ||||
| @@ -172,7 +182,8 @@ public class UpdateModule extends ReactContextBaseJavaModule{ | ||||
|  | ||||
|     @ReactMethod | ||||
|     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() { | ||||
|             @Override | ||||
| @@ -213,7 +224,8 @@ public class UpdateModule extends ReactContextBaseJavaModule{ | ||||
|  | ||||
|     @ReactMethod | ||||
|     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() { | ||||
|             @Override | ||||
|   | ||||
| @@ -256,6 +256,9 @@ RCT_EXPORT_METHOD(downloadPatchFromPpk:(NSDictionary *)options | ||||
| RCT_EXPORT_METHOD(setNeedUpdate:(NSDictionary *)options) | ||||
| { | ||||
|     NSString *hash = options[@"hash"]; | ||||
|     if (hash.length <= 0) { | ||||
|         hash = options[@"hashName"]; | ||||
|     } | ||||
|     if (hash.length) { | ||||
|         NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | ||||
|         NSString *lastVersion = nil; | ||||
| @@ -279,6 +282,9 @@ RCT_EXPORT_METHOD(setNeedUpdate:(NSDictionary *)options) | ||||
| RCT_EXPORT_METHOD(reloadUpdate:(NSDictionary *)options) | ||||
| { | ||||
|     NSString *hash = options[@"hash"]; | ||||
|     if (hash.length <= 0) { | ||||
|         hash = options[@"hashName"]; | ||||
|     } | ||||
|     if (hash.length) { | ||||
|         [self setNeedUpdate:options]; | ||||
|          | ||||
| @@ -335,6 +341,9 @@ RCT_EXPORT_METHOD(markSuccess) | ||||
| { | ||||
|     NSString *updateUrl = [RCTConvert NSString:options[@"updateUrl"]]; | ||||
|     NSString *hash = [RCTConvert NSString:options[@"hash"]]; | ||||
|     if (hash.length <= 0) { | ||||
|         hash = [RCTConvert NSString:options[@"hashName"]];; | ||||
|     } | ||||
|     if (updateUrl.length <= 0 || hash.length <= 0) { | ||||
|         callback([self errorWithMessage:ERROR_OPTIONS]); | ||||
|         return; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 sunnylqm
					sunnylqm