1// Copyright 2019-present 650 Industries. All rights reserved.
2#if __has_include(<EXBranch/RNBranch.h>)
3#import "EXScopedBranch.h"
4
5@interface EXScopedBranch ()
6
7@property (nonatomic, weak) UMModuleRegistry *moduleRegistry;
8
9@end
10
11@protocol EXDummyBranchProtocol
12@end
13
14@implementation EXScopedBranch
15
16@synthesize bridge = _bridge;
17
18+ (const NSArray<Protocol *> *)exportedInterfaces
19{
20  return @[@protocol(EXDummyBranchProtocol)];
21}
22
23- (instancetype)initWithExperienceId:(NSString *)experienceId
24{
25  if (self = [super init]) {
26    [[NSNotificationCenter defaultCenter] removeObserver:self name:RNBranchLinkOpenedNotification object:nil];
27    _experienceId = experienceId;
28  }
29  return self;
30}
31
32- (void)setModuleRegistry:(UMModuleRegistry *)moduleRegistry
33{
34  _moduleRegistry = moduleRegistry;
35  [(id<EXBranchScopedModuleDelegate>)[_moduleRegistry getSingletonModuleForName:@"BranchManager"] branchModuleDidInit:self];
36}
37
38- (void)setBridge:(RCTBridge *)bridge
39{
40  _bridge = bridge;
41#pragma clang diagnostic push
42#pragma clang diagnostic ignored "-Wundeclared-selector"
43  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onInitSessionFinished:) name:RNBranchLinkOpenedNotification object:nil];
44#pragma clang diagnostic pop
45}
46
47@end
48#endif
49