Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[iOS] Only use __enable_native_promise__ option when explicitly set i…
Browse files Browse the repository at this point in the history
…n config. (#1617)
  • Loading branch information
wqyfavor authored and cxfeng1 committed Oct 3, 2018
1 parent 1268a6d commit 5cbf24b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ namespace WeexCore
void PostMessage(const char* vm_id, const char* data, int dataLength) override {};
void DispatchMessage(const char* client_id,
const char* data, int dataLength, const char* callback, const char* vm_id) override {};
void OnReceivedResult(long callback_id, std::unique_ptr<WeexJSResult>& result) override {};
};

class WXCoreMeasureFunctionBridge : public MeasureFunctionAdapter
Expand Down
18 changes: 16 additions & 2 deletions ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#import <CommonCrypto/CommonCrypto.h>
#import <CoreText/CoreText.h>
#import "WXAppMonitorProtocol.h"

#import "WXConfigCenterProtocol.h"
#import "WXTextComponent.h"

#define KEY_PASSWORD @"com.taobao.Weex.123456"
Expand Down Expand Up @@ -209,7 +209,7 @@ + (NSDictionary *)getEnvironment

NSMutableDictionary *data = [NSMutableDictionary dictionaryWithDictionary:@{
@"platform":platform,
@"osName":platform,//osName is eaqual to platorm name in native
@"osName":platform, //osName is eaqual to platorm name in native
@"osVersion":sysVersion,
@"weexVersion":weexVersion,
@"deviceModel":machine,
Expand All @@ -220,6 +220,20 @@ + (NSDictionary *)getEnvironment
@"scale":@(scale),
@"logLevel":[WXLog logLevelString] ?: @"error"
}];

if ([[[UIDevice currentDevice] systemVersion] integerValue] >= 11) {
id configCenter = [WXSDKEngine handlerForProtocol:@protocol(WXConfigCenterProtocol)];
if ([configCenter respondsToSelector:@selector(configForKey:defaultValue:isDefault:)]) {
// update
BOOL isDefault = YES;
BOOL jsfmEnableNativePromiseOnIOS11AndLater = [[configCenter configForKey:@"iOS_weex_ext_config.jsfmEnableNativePromiseOnIOS11AndLater" defaultValue:@(NO) isDefault:&isDefault] boolValue];
if (!isDefault) {
// has this config explicitly
data[@"__enable_native_promise__"] = @(jsfmEnableNativePromiseOnIOS11AndLater);
}
}
}

if ([WXSDKEngine customEnvironment]) {
[data addEntriesFromDictionary:[WXSDKEngine customEnvironment]];
}
Expand Down

0 comments on commit 5cbf24b

Please sign in to comment.