1// Copyright 2015-present 650 Industries. All rights reserved. 2 3#import "EXConstantsBinding.h" 4#import "EXUnversioned.h" 5 6@interface EXConstantsBinding () 7 8@property (nonatomic, strong) NSString *appOwnership; 9@property (nonatomic, strong) NSDictionary *unversionedConstants; 10 11@end 12 13@implementation EXConstantsBinding : EXConstantsService 14 15- (instancetype)initWithParams:(NSDictionary *)params 16{ 17 if (self = [super init]) { 18 _unversionedConstants = params[@"constants"]; 19 if (_unversionedConstants && _unversionedConstants[@"appOwnership"]) { 20 _appOwnership = _unversionedConstants[@"appOwnership"]; 21 } 22 } 23 return self; 24} 25 26- (NSDictionary *)constants 27{ 28 NSMutableDictionary *constants = [[super constants] mutableCopy]; 29 30 [constants setValue:[self expoClientVersion] forKey:@"expoVersion"]; 31 32 BOOL isDetached = NO; 33#ifdef EX_DETACHED 34 isDetached = YES; 35#endif 36 37 constants[@"isDetached"] = @(isDetached); 38 39 if (_unversionedConstants) { 40 [constants addEntriesFromDictionary:_unversionedConstants]; 41 } 42 43 if ([constants[@"appOwnership"] isEqualToString:@"expo"]) { 44 NSMutableDictionary *platform = [constants[@"platform"] mutableCopy]; 45 NSMutableDictionary *ios = [platform[@"ios"] mutableCopy]; 46 [ios setValue:[NSNull null] forKey:@"buildNumber"]; 47 [platform setValue:ios forKey:@"ios"]; 48 [constants setValue:platform forKey:@"platform"]; 49 } 50 51 return constants; 52} 53 54- (NSString *)expoClientVersion 55{ 56 NSString *expoClientVersion = _unversionedConstants[EX_UNVERSIONED(@"expoRuntimeVersion")]; 57 if (expoClientVersion) { 58 return expoClientVersion; 59 } else { 60 // not correct in standalone apps 61 return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; 62 } 63} 64 65@end 66