1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

修复BUG: 编译报错及低版本设备报错

This commit is contained in:
tdzl2003 2016-05-04 23:49:07 +08:00
parent 73684eb576
commit 35befab91a

View File

@ -106,7 +106,7 @@ RCT_EXPORT_MODULE(RCTHotUpdate);
// ...need clear files later // ...need clear files later
} }
else if (isFirstTime){ else if (isFirstTime){
NSMutableDictionary *newInfo = [updateInfo mutableCopy]; NSMutableDictionary *newInfo = [[NSMutableDictionary alloc] initWithDictionary:updateInfo];
newInfo[paramIsFirstTime] = @(NO); newInfo[paramIsFirstTime] = @(NO);
[defaults setObject:newInfo forKey:keyUpdateInfo]; [defaults setObject:newInfo forKey:keyUpdateInfo];
[defaults setObject:@(YES) forKey:keyFirstLoadLoadMarked]; [defaults setObject:@(YES) forKey:keyFirstLoadLoadMarked];
@ -176,7 +176,7 @@ RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary *)options
{ {
[self hotUpdate:HotUpdateTypeFullDownload options:options callback:^(NSError *error) { [self hotUpdate:HotUpdateTypeFullDownload options:options callback:^(NSError *error) {
if (error) { if (error) {
[self reject:reject error:error]; [reject error];
} }
else { else {
resolve(nil); resolve(nil);
@ -190,7 +190,7 @@ RCT_EXPORT_METHOD(downloadPatchFromPackage:(NSDictionary *)options
{ {
[self hotUpdate:HotUpdateTypePatchFromPackage options:options callback:^(NSError *error) { [self hotUpdate:HotUpdateTypePatchFromPackage options:options callback:^(NSError *error) {
if (error) { if (error) {
[self reject:reject error:error]; [reject error];
} }
else { else {
resolve(nil); resolve(nil);
@ -204,7 +204,7 @@ RCT_EXPORT_METHOD(downloadPatchFromPpk:(NSDictionary *)options
{ {
[self hotUpdate:HotUpdateTypePatchFromPpk options:options callback:^(NSError *error) { [self hotUpdate:HotUpdateTypePatchFromPpk options:options callback:^(NSError *error) {
if (error) { if (error) {
[self reject:reject error:error]; [reject error];
} }
else { else {
resolve(nil); resolve(nil);
@ -223,7 +223,7 @@ RCT_EXPORT_METHOD(setNeedUpdate:(NSDictionary *)options)
lastVersion = updateInfo[paramCurrentVersion]; lastVersion = updateInfo[paramCurrentVersion];
} }
NSMutableDictionary *newInfo = [@{} mutableCopy]; NSMutableDictionary *newInfo = [[NSMutableDictionary alloc] init];
newInfo[paramCurrentVersion] = hashName; newInfo[paramCurrentVersion] = hashName;
newInfo[paramLastVersion] = lastVersion; newInfo[paramLastVersion] = lastVersion;
newInfo[paramIsFirstTime] = @(YES); newInfo[paramIsFirstTime] = @(YES);
@ -253,7 +253,7 @@ RCT_EXPORT_METHOD(markSuccess)
{ {
// update package info // update package info
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableDictionary *packageInfo = [[defaults objectForKey:keyUpdateInfo] mutableCopy]; NSMutableDictionary *packageInfo = [[NSMutableDictionary alloc] initWithDictionary:[defaults objectForKey:keyUpdateInfo]];
[packageInfo setObject:@(NO) forKey:paramIsFirstTime]; [packageInfo setObject:@(NO) forKey:paramIsFirstTime];
[packageInfo setObject:@(YES) forKey:paramIsFirstLoadOk]; [packageInfo setObject:@(YES) forKey:paramIsFirstLoadOk];
[defaults setObject:packageInfo forKey:keyUpdateInfo]; [defaults setObject:packageInfo forKey:keyUpdateInfo];
@ -414,11 +414,6 @@ RCT_EXPORT_METHOD(markSuccess)
} }
} }
- (void)reject:(RCTPromiseRejectBlock)reject error:(NSError *)error
{
reject([NSString stringWithFormat: @"%lu", (long)error.code], error.localizedDescription, error);
}
- (NSError *)errorWithMessage:(NSString *)errorMessage - (NSError *)errorWithMessage:(NSString *)errorMessage
{ {
return [NSError errorWithDomain:@"cn.reactnative.hotupdate" return [NSError errorWithDomain:@"cn.reactnative.hotupdate"