Add set local hash info for ios
This commit is contained in:
parent
775e567062
commit
94d52bb415
android/src/main/java/cn/reactnative/modules/update
ios/RCTPushy
lib
@ -147,7 +147,7 @@ public class UpdateContext {
|
||||
String lastVersion = getCurrentVersion();
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putString("currentVersion", hash);
|
||||
if (lastVersion != null && lastVersion != hash) {
|
||||
if (lastVersion != null && !lastVersion.equals(hash)) {
|
||||
editor.putString("lastVersion", lastVersion);
|
||||
}
|
||||
editor.putBoolean("firstTime", true);
|
||||
@ -189,7 +189,8 @@ public class UpdateContext {
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putBoolean("firstTimeOk", true);
|
||||
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("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/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 "RCTPushyDownloader.h"
|
||||
#import "RCTPushyManager.h"
|
||||
@ -23,6 +15,7 @@ static NSString *const paramIsFirstTime = @"isFirstTime";
|
||||
static NSString *const paramIsFirstLoadOk = @"isFirstLoadOK";
|
||||
static NSString *const keyBlockUpdate = @"REACTNATIVECN_PUSHY_BLOCKUPDATE";
|
||||
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 keyRolledBackMarked = @"REACTNATIVECN_PUSHY_ROLLEDBACKMARKED_KEY";
|
||||
static NSString *const KeyPackageUpdatedMarked = @"REACTNATIVECN_PUSHY_ISPACKAGEUPDATEDMARKED_KEY";
|
||||
@ -212,6 +205,24 @@ RCT_EXPORT_METHOD(setUuid:(NSString *)uuid)
|
||||
[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
|
||||
resolver:(RCTPromiseResolveBlock)resolve
|
||||
rejecter:(RCTPromiseRejectBlock)reject)
|
||||
@ -304,10 +315,16 @@ RCT_EXPORT_METHOD(markSuccess)
|
||||
{
|
||||
// up package info
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSMutableDictionary *packageInfo = [[NSMutableDictionary alloc] initWithDictionary:[defaults objectForKey:keyPushyInfo]];
|
||||
[packageInfo setObject:@(NO) forKey:paramIsFirstTime];
|
||||
[packageInfo setObject:@(YES) forKey:paramIsFirstLoadOk];
|
||||
[defaults setObject:packageInfo forKey:keyPushyInfo];
|
||||
NSMutableDictionary *pushyInfo = [[NSMutableDictionary alloc] initWithDictionary:[defaults objectForKey:keyPushyInfo]];
|
||||
[pushyInfo setObject:@(NO) forKey:paramIsFirstTime];
|
||||
[pushyInfo setObject:@(YES) forKey:paramIsFirstLoadOk];
|
||||
|
||||
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];
|
||||
|
||||
// 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>
|
||||
|
||||
@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"
|
||||
|
||||
@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>
|
||||
|
||||
@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 "ZipArchive.h"
|
||||
#import "HDiffPatch.h"
|
||||
|
@ -51,7 +51,7 @@ export async function getCurrentVersionInfo() {
|
||||
const eventEmitter = new NativeEventEmitter(Pushy);
|
||||
|
||||
if (!uuid) {
|
||||
uuid = require('nanoid/non-secure')();
|
||||
uuid = require('nanoid/non-secure').nanoid();
|
||||
Pushy.setUuid(uuid);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user