Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[expo-branch] First 3rd party library unimodule wrapper! (#5165)
We would like to provide a way to users to optionally include `react-native-branch` in their standalone apps. Fixes #5132. I added support for React Native-specific unimodules to React Native adapter. Right now it works like this: - unimodule `expo-branch` depends on `react-native`, so it can use its API. It's no longer a uni-platform module, more an optinmodule (I guess the name won't stick) - we copy `react-native-branch` vendored module directly to the unimodule. It will compile, since we added necessary dependencies to the unimodule - `BranchPackage < org.unimodules.Package` implements `ReactPackage` interface too, forwarding all the calls to the vendored `RNBranchPackage`. - when the module registry provider creates a module registry from a list of `Packages`, it can filter out `ReactPackages` — and so it does, putting them into a local internal module (`ReactPackagesProvider`) which only purpose is to carry those to `ModuleRegistryAdapter` which is responsible for creating a list of React Native modules out of a module registry. The adapter grabs the `ReactPackagesProvider` and adds React Native modules to the list. I have confirmed that adding `BranchPackage` to a list of installed unimodules' packages creates `RNBranchModule` and exports to JS.
- Loading branch information
Showing
100 changed files
with
32,109 additions
and
29,748 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2015-present 650 Industries. All rights reserved. | ||
|
||
#import <UIKit/UIKit.h> | ||
#import <EXBranch/EXBranchManager.h> | ||
#import "EXKernelService.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
* Handles logic for Branch deep links and integration with the versioned | ||
* RN bindings. Based loosely on RNBranch.h but handles versionning and limit | ||
* usage to standalone apps. | ||
*/ | ||
@interface EXScopedBranchManager : EXBranchManager <EXKernelService> | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
51 changes: 12 additions & 39 deletions
51
...xponent/Kernel/Services/EXBranchManager.m → ...t/Kernel/Services/EXScopedBranchManager.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
ios/Exponent/Versioned/Core/UniversalModules/EXScopedBranch.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2019-present 650 Industries. All rights reserved. | ||
|
||
#if __has_include(<EXBranch/RNBranch.h>) | ||
#import <EXBranch/RNBranch.h> | ||
#import <UMCore/UMInternalModule.h> | ||
#import <UMCore/UMModuleRegistryConsumer.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@protocol EXBranchScopedModuleDelegate | ||
|
||
- (void)branchModuleDidInit:(id _Nonnull)branchModule; | ||
|
||
@end | ||
|
||
@interface EXScopedBranch : RNBranch <UMModuleRegistryConsumer, UMInternalModule> | ||
|
||
@property (nonatomic, strong) NSString *experienceId; | ||
|
||
- (instancetype)initWithExperienceId:(NSString *)experienceId; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END | ||
#endif |
48 changes: 48 additions & 0 deletions
48
ios/Exponent/Versioned/Core/UniversalModules/EXScopedBranch.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2019-present 650 Industries. All rights reserved. | ||
#if __has_include(<EXBranch/RNBranch.h>) | ||
#import "EXScopedBranch.h" | ||
|
||
@interface EXScopedBranch () | ||
|
||
@property (nonatomic, weak) UMModuleRegistry *moduleRegistry; | ||
|
||
@end | ||
|
||
@protocol EXDummyBranchProtocol | ||
@end | ||
|
||
@implementation EXScopedBranch | ||
|
||
@synthesize bridge = _bridge; | ||
|
||
+ (const NSArray<Protocol *> *)exportedInterfaces | ||
{ | ||
return @[@protocol(EXDummyBranchProtocol)]; | ||
} | ||
|
||
- (instancetype)initWithExperienceId:(NSString *)experienceId | ||
{ | ||
if (self = [super init]) { | ||
[[NSNotificationCenter defaultCenter] removeObserver:self name:RNBranchLinkOpenedNotification object:nil]; | ||
_experienceId = experienceId; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)setModuleRegistry:(UMModuleRegistry *)moduleRegistry | ||
{ | ||
_moduleRegistry = moduleRegistry; | ||
[(id<EXBranchScopedModuleDelegate>)[_moduleRegistry getSingletonModuleForName:@"BranchManager"] branchModuleDidInit:self]; | ||
} | ||
|
||
- (void)setBridge:(RCTBridge *)bridge | ||
{ | ||
_bridge = bridge; | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wundeclared-selector" | ||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onInitSessionFinished:) name:RNBranchLinkOpenedNotification object:nil]; | ||
#pragma clang diagnostic pop | ||
} | ||
|
||
@end | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.