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) EXModuleRegistry *exModuleRegistry;
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)initWithScopeKey:(NSString *)scopeKey
24{
25  if (self = [super init]) {
26    [[NSNotificationCenter defaultCenter] removeObserver:self name:RNBranchLinkOpenedNotification object:nil];
27    _scopeKey = scopeKey;
28  }
29  return self;
30}
31
32- (void)setModuleRegistry:(EXModuleRegistry *)exModuleRegistry
33{
34  _exModuleRegistry = exModuleRegistry;
35  [(id<EXBranchScopedModuleDelegate>)[_exModuleRegistry 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