iOS:get environment information in main thread
This commit is contained in:
parent
8e79ce3bad
commit
99dd7f9231
@ -29,6 +29,7 @@
|
||||
@interface DoricJSEngine ()
|
||||
@property(nonatomic, strong) NSMutableDictionary *timers;
|
||||
@property(nonatomic, strong) DoricBridgeExtension *bridgeExtension;
|
||||
@property(nonatomic, strong) NSDictionary *innerEnvironmentDictionary;
|
||||
@end
|
||||
|
||||
@implementation DoricJSEngine
|
||||
@ -37,6 +38,18 @@ - (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
_jsQueue = dispatch_queue_create("doric.jsengine", DISPATCH_QUEUE_SERIAL);
|
||||
_bridgeExtension = [[DoricBridgeExtension alloc] init];
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
|
||||
_innerEnvironmentDictionary = @{
|
||||
@"platform": @"iOS",
|
||||
@"platformVersion": [[UIDevice currentDevice] systemVersion],
|
||||
@"appName": infoDictionary[@"CFBundleName"],
|
||||
@"appVersion": infoDictionary[@"CFBundleShortVersionString"],
|
||||
@"screenWidth": @([[UIScreen mainScreen] bounds].size.width),
|
||||
@"screenHeight": @([[UIScreen mainScreen] bounds].size.height),
|
||||
@"statusBarHeight": @([[UIApplication sharedApplication] statusBarFrame].size.height),
|
||||
};
|
||||
});
|
||||
dispatch_async(_jsQueue, ^() {
|
||||
self.timers = [[NSMutableDictionary alloc] init];
|
||||
[self initJSEngine];
|
||||
@ -54,17 +67,7 @@ - (void)initJSEngine {
|
||||
|
||||
- (void)initJSExecutor {
|
||||
__weak typeof(self) _self = self;
|
||||
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
|
||||
NSMutableDictionary *envDic = [@{
|
||||
@"platform": @"iOS",
|
||||
@"platformVersion": [[UIDevice currentDevice] systemVersion],
|
||||
@"appName": infoDictionary[@"CFBundleName"],
|
||||
@"appVersion": infoDictionary[@"CFBundleShortVersionString"],
|
||||
@"screenWidth": @([[UIScreen mainScreen] bounds].size.width),
|
||||
@"screenHeight": @([[UIScreen mainScreen] bounds].size.height),
|
||||
@"statusBarHeight": @([[UIApplication sharedApplication] statusBarFrame].size.height),
|
||||
} mutableCopy];
|
||||
|
||||
NSMutableDictionary *envDic = [self.innerEnvironmentDictionary mutableCopy];
|
||||
[self.registry.environmentVariables enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) {
|
||||
envDic[key] = obj;
|
||||
}];
|
||||
|
Reference in New Issue
Block a user