mirror of
				https://gitcode.com/gh_mirrors/re/react-native-pushy.git
				synced 2025-10-31 21:33:12 +08:00 
			
		
		
		
	Add set local hash info for ios
This commit is contained in:
		| @@ -147,7 +147,7 @@ public class UpdateContext { | |||||||
|         String lastVersion = getCurrentVersion(); |         String lastVersion = getCurrentVersion(); | ||||||
|         SharedPreferences.Editor editor = sp.edit(); |         SharedPreferences.Editor editor = sp.edit(); | ||||||
|         editor.putString("currentVersion", hash); |         editor.putString("currentVersion", hash); | ||||||
|         if (lastVersion != null && lastVersion != hash) { |         if (lastVersion != null && !lastVersion.equals(hash)) { | ||||||
|             editor.putString("lastVersion", lastVersion); |             editor.putString("lastVersion", lastVersion); | ||||||
|         } |         } | ||||||
|         editor.putBoolean("firstTime", true); |         editor.putBoolean("firstTime", true); | ||||||
| @@ -189,7 +189,8 @@ public class UpdateContext { | |||||||
|         SharedPreferences.Editor editor = sp.edit(); |         SharedPreferences.Editor editor = sp.edit(); | ||||||
|         editor.putBoolean("firstTimeOk", true); |         editor.putBoolean("firstTimeOk", true); | ||||||
|         String lastVersion = sp.getString("lastVersion", null); |         String lastVersion = sp.getString("lastVersion", null); | ||||||
|         if (lastVersion != null) { |         String curVersion = sp.getString("currentVersion", null); | ||||||
|  |         if (lastVersion != null && !lastVersion.equals(curVersion)) { | ||||||
|             editor.remove("lastVersion"); |             editor.remove("lastVersion"); | ||||||
|             editor.remove("hash_" + lastVersion); |             editor.remove("hash_" + lastVersion); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -1,11 +1,3 @@ | |||||||
| // |  | ||||||
| //  RCTPushy.h |  | ||||||
| //  RCTPushy |  | ||||||
| // |  | ||||||
| //  Created by LvBingru on 2/19/16. |  | ||||||
| //  Copyright © 2016 erica. All rights reserved. |  | ||||||
| // |  | ||||||
|  |  | ||||||
| #import <React/RCTBridgeModule.h> | #import <React/RCTBridgeModule.h> | ||||||
| #import <React/RCTEventEmitter.h> | #import <React/RCTEventEmitter.h> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,11 +1,3 @@ | |||||||
| // |  | ||||||
| //  RCTPushy.m |  | ||||||
| //  RCTPushy |  | ||||||
| // |  | ||||||
| //  Created by LvBingru on 2/19/16. |  | ||||||
| //  Copyright © 2016 erica. All rights reserved. |  | ||||||
| // |  | ||||||
|  |  | ||||||
| #import "RCTPushy.h" | #import "RCTPushy.h" | ||||||
| #import "RCTPushyDownloader.h" | #import "RCTPushyDownloader.h" | ||||||
| #import "RCTPushyManager.h" | #import "RCTPushyManager.h" | ||||||
| @@ -23,6 +15,7 @@ static NSString *const paramIsFirstTime = @"isFirstTime"; | |||||||
| static NSString *const paramIsFirstLoadOk = @"isFirstLoadOK"; | static NSString *const paramIsFirstLoadOk = @"isFirstLoadOK"; | ||||||
| static NSString *const keyBlockUpdate = @"REACTNATIVECN_PUSHY_BLOCKUPDATE"; | static NSString *const keyBlockUpdate = @"REACTNATIVECN_PUSHY_BLOCKUPDATE"; | ||||||
| static NSString *const keyUuid = @"REACTNATIVECN_PUSHY_UUID"; | static NSString *const keyUuid = @"REACTNATIVECN_PUSHY_UUID"; | ||||||
|  | static NSString *const keyHashInfo = @"REACTNATIVECN_PUSHY_HASH_"; | ||||||
| static NSString *const keyFirstLoadMarked = @"REACTNATIVECN_PUSHY_FIRSTLOADMARKED_KEY"; | static NSString *const keyFirstLoadMarked = @"REACTNATIVECN_PUSHY_FIRSTLOADMARKED_KEY"; | ||||||
| static NSString *const keyRolledBackMarked = @"REACTNATIVECN_PUSHY_ROLLEDBACKMARKED_KEY"; | static NSString *const keyRolledBackMarked = @"REACTNATIVECN_PUSHY_ROLLEDBACKMARKED_KEY"; | ||||||
| static NSString *const KeyPackageUpdatedMarked = @"REACTNATIVECN_PUSHY_ISPACKAGEUPDATEDMARKED_KEY"; | static NSString *const KeyPackageUpdatedMarked = @"REACTNATIVECN_PUSHY_ISPACKAGEUPDATEDMARKED_KEY"; | ||||||
| @@ -212,6 +205,24 @@ RCT_EXPORT_METHOD(setUuid:(NSString *)uuid) | |||||||
|     [defaults synchronize]; |     [defaults synchronize]; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | RCT_EXPORT_METHOD(setLocalHashInfo:(NSString *)hash | ||||||
|  |                   value:(NSString *)value) | ||||||
|  | { | ||||||
|  |     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | ||||||
|  |     [defaults setObject:value forKey:[keyHashInfo stringByAppendingString:hash]]; | ||||||
|  |     [defaults synchronize]; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | RCT_EXPORT_METHOD(getLocalHashInfo:(NSString *)hash | ||||||
|  |                   resolver:(RCTPromiseResolveBlock)resolve | ||||||
|  |                   rejecter:(RCTPromiseRejectBlock)reject) | ||||||
|  | { | ||||||
|  |      | ||||||
|  |     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | ||||||
|  |     resolve([defaults stringForKey:[keyHashInfo stringByAppendingString:hash]]); | ||||||
|  | } | ||||||
|  |  | ||||||
| RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary *)options | RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary *)options | ||||||
|                   resolver:(RCTPromiseResolveBlock)resolve |                   resolver:(RCTPromiseResolveBlock)resolve | ||||||
|                   rejecter:(RCTPromiseRejectBlock)reject) |                   rejecter:(RCTPromiseRejectBlock)reject) | ||||||
| @@ -304,10 +315,16 @@ RCT_EXPORT_METHOD(markSuccess) | |||||||
| { | { | ||||||
|     // up package info |     // up package info | ||||||
|     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; |     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | ||||||
|     NSMutableDictionary *packageInfo = [[NSMutableDictionary alloc] initWithDictionary:[defaults objectForKey:keyPushyInfo]]; |     NSMutableDictionary *pushyInfo = [[NSMutableDictionary alloc] initWithDictionary:[defaults objectForKey:keyPushyInfo]]; | ||||||
|     [packageInfo setObject:@(NO) forKey:paramIsFirstTime]; |     [pushyInfo setObject:@(NO) forKey:paramIsFirstTime]; | ||||||
|     [packageInfo setObject:@(YES) forKey:paramIsFirstLoadOk]; |     [pushyInfo setObject:@(YES) forKey:paramIsFirstLoadOk]; | ||||||
|     [defaults setObject:packageInfo forKey:keyPushyInfo]; |      | ||||||
|  |     NSString *lastVersion = pushyInfo[paramLastVersion]; | ||||||
|  |     NSString *curVersion = pushyInfo[paramCurrentVersion]; | ||||||
|  |     if (lastVersion != nil && ![lastVersion isEqualToString:curVersion]) { | ||||||
|  |         [pushyInfo removeObjectForKey:[keyHashInfo stringByAppendingString:lastVersion]]; | ||||||
|  |     } | ||||||
|  |     [defaults setObject:pushyInfo forKey:keyPushyInfo]; | ||||||
|     [defaults synchronize]; |     [defaults synchronize]; | ||||||
|      |      | ||||||
|     // clear other package dir |     // clear other package dir | ||||||
|   | |||||||
| @@ -1,11 +1,3 @@ | |||||||
| // |  | ||||||
| //  RCTPushyDownloader.h |  | ||||||
| //  RCTPushy |  | ||||||
| // |  | ||||||
| //  Created by lvbingru on 16/2/23. |  | ||||||
| //  Copyright © 2016年 erica. All rights reserved. |  | ||||||
| // |  | ||||||
|  |  | ||||||
| #import <Foundation/Foundation.h> | #import <Foundation/Foundation.h> | ||||||
|  |  | ||||||
| @interface RCTPushyDownloader : NSObject | @interface RCTPushyDownloader : NSObject | ||||||
|   | |||||||
| @@ -1,11 +1,3 @@ | |||||||
| // |  | ||||||
| //  RCTPushyDownloader.m |  | ||||||
| //  RCTPushy |  | ||||||
| // |  | ||||||
| //  Created by lvbingru on 16/2/23. |  | ||||||
| //  Copyright © 2016年 erica. All rights reserved. |  | ||||||
| // |  | ||||||
|  |  | ||||||
| #import "RCTPushyDownloader.h" | #import "RCTPushyDownloader.h" | ||||||
|  |  | ||||||
| @interface RCTPushyDownloader()<NSURLSessionDelegate> | @interface RCTPushyDownloader()<NSURLSessionDelegate> | ||||||
|   | |||||||
| @@ -1,11 +1,3 @@ | |||||||
| // |  | ||||||
| //  RCTPushyManager.h |  | ||||||
| //  RCTPushy |  | ||||||
| // |  | ||||||
| //  Created by lvbingru on 16/4/1. |  | ||||||
| //  Copyright © 2016年 erica. All rights reserved. |  | ||||||
| // |  | ||||||
|  |  | ||||||
| #import <Foundation/Foundation.h> | #import <Foundation/Foundation.h> | ||||||
|  |  | ||||||
| @interface RCTPushyManager : NSObject | @interface RCTPushyManager : NSObject | ||||||
|   | |||||||
| @@ -1,11 +1,3 @@ | |||||||
| // |  | ||||||
| //  RCTPushyManager.m |  | ||||||
| //  RCTPushy |  | ||||||
| // |  | ||||||
| //  Created by lvbingru on 16/4/1. |  | ||||||
| //  Copyright © 2016年 erica. All rights reserved. |  | ||||||
| // |  | ||||||
|  |  | ||||||
| #import "RCTPushyManager.h" | #import "RCTPushyManager.h" | ||||||
| #import "ZipArchive.h" | #import "ZipArchive.h" | ||||||
| #import "HDiffPatch.h" | #import "HDiffPatch.h" | ||||||
|   | |||||||
| @@ -51,7 +51,7 @@ export async function getCurrentVersionInfo() { | |||||||
| const eventEmitter = new NativeEventEmitter(Pushy); | const eventEmitter = new NativeEventEmitter(Pushy); | ||||||
|  |  | ||||||
| if (!uuid) { | if (!uuid) { | ||||||
|   uuid = require('nanoid/non-secure')(); |   uuid = require('nanoid/non-secure').nanoid(); | ||||||
|   Pushy.setUuid(uuid); |   Pushy.setUuid(uuid); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 sunnylqm
					sunnylqm