1// Copyright 2019-present 650 Industries. All rights reserved. 2 3#import <EXBranch/EXBranchManager.h> 4#import <ExpoModulesCore/EXDefines.h> 5#import <Branch/Branch.h> 6 7@implementation EXBranchManager 8 9EX_REGISTER_SINGLETON_MODULE(BranchManager) 10 11+ (BOOL)isBranchEnabled 12{ 13 id branchKey = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"branch_key"]; 14 return (branchKey != nil); 15} 16 17#pragma mark - linking hooks 18 19- (void)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 20{ 21 if ([[self class] isBranchEnabled]) { 22 [RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES]; 23 } 24} 25 26- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler 27{ 28 if (![[self class] isBranchEnabled]) { 29 return NO; 30 } 31 return [RNBranch continueUserActivity:userActivity]; 32} 33 34- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(nullable NSString *)sourceApplication annotation:(id)annotation 35{ 36 if (![[self class] isBranchEnabled]) { 37 return NO; 38 } 39 return [RNBranch.branch application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; 40} 41 42@end 43