Skip to content

Commit

Permalink
Merge pull request #551 from BranchMetrics/INTENG-8649-fb-deep-linkin…
Browse files Browse the repository at this point in the history
…g-class

[INTENG-8649] Facebook deep linking class
  • Loading branch information
jdee authored Mar 11, 2020
2 parents 4feb8cf + 3644288 commit 02cf838
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ android/build
.idea

Pods

# for now. not such a great idea. need to sort the bundler 1.x/2.x issue here.
Gemfile.lock
13 changes: 13 additions & 0 deletions android/src/main/java/io/branch/rnbranch/RNBranchConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,17 @@ public boolean getUseTestInstance() {
return false;
}
}

public boolean getEnableFacebookLinkCheck() {
if (mConfiguration == null) return false;

try {
if (!mConfiguration.has("enableFacebookLinkCheck")) return false;
return mConfiguration.getBoolean("enableFacebookLinkCheck");
}
catch (JSONException exception) {
Log.e(TAG, "Error parsing branch.json: " + exception.getMessage());
return false;
}
}
}
4 changes: 3 additions & 1 deletion android/src/main/java/io/branch/rnbranch/RNBranchModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private void generateLocalBroadcast(JSONObject referringParams,
LocalBroadcastManager.getInstance(mmActivity).sendBroadcast(broadcastIntent);
}
}.init(reactActivity);

branch.initSession(referralInitListener, uri, reactActivity);
}

Expand Down Expand Up @@ -687,6 +687,8 @@ private static Branch setupBranch(Context context) {

if (mUseDebug || config.getDebugMode()) branch.setDebug();

if (config.getEnableFacebookLinkCheck()) branch.enableFacebookAppLinkCheck();

if (mRequestMetadata != null) {
Iterator keys = mRequestMetadata.keys();
while (keys.hasNext()) {
Expand Down
6 changes: 3 additions & 3 deletions docs/branch.json.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ of `branch.json`.
## Contents

Note that support for setting Branch keys on Android in branch.json requires
version 3.x of react-native-branch, using [RNBranchModule.getAutoInstance()](../README.md#updating-from-an-earlier-version-or-starting-with-v300)
version 3.x of react-native-branch, using [RNBranchModule.getAutoInstance()](https://help.branch.io/developers-hub/docs/react-native#section-updating-from-an-earlier-version-or-starting-with-v-3-0-0)

|key|description|type|
|---|---|---|
|appleSearchAdsDebugMode|If true, `setAppleSearchAdsDebugMode` will be called on the iOS Branch instance. Ignored on Android.|Boolean|
|branchKey|The Branch key to use. Overrides liveKey, testKey and useTestInstance.|String|
|liveKey|The live Branch key to use if useTestInstance is false. Ignored if useTestInstance is true or branchKey is present.|String|
|debugMode|If true, `setDebug` will be called in the native SDK, enabling testing of install events.|Boolean|
|delayInitToCheckForSearchAds|If true, `delayInitToCheckForSearchAds` will be called on the iOS Branch instance. Ignored on Android.|Boolean|
|enableFacebookLinkCheck|If true, results in calling `enableFacebookAppLinkCheck()` in the Branch Android SDK and `registerFacebookDeepLinkingClass:` in the Branch iOS SDK.|Boolean|
|testKey|The test Branch key to use if useTestInstance is true. Ignored if useTestInstance is false or branchKey is present.|String|
|useTestInstance|Determines whether liveKey or testKey is used if branchKey is not present.|Boolean|

Expand All @@ -115,6 +115,6 @@ See [branch.example.json](https://github.com/BranchMetrics/react-native-branch-d
"testKey": "key_test_yyyy",
"useTestInstance": true,
"delayInitToCheckForSearchAds": true,
"appleSearchAdsDebugMode": true
"enableFacebookLinkCheck": true
}
```
15 changes: 12 additions & 3 deletions ios/RNBranch.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ + (void)setupBranchInstance:(Branch *)instance
if (config.delayInitToCheckForSearchAds) {
[instance delayInitToCheckForSearchAds];
}
if (config.enableFacebookLinkCheck) {
Class FBSDKAppLinkUtility = NSClassFromString(@"FBSDKAppLinkUtility");
if (FBSDKAppLinkUtility) {
[instance registerFacebookDeepLinkingClass:FBSDKAppLinkUtility];
}
else {
RCTLogWarn(@"FBSDKAppLinkUtility not found but enableFacebookLinkCheck set to true. Please be sure you have integrated the Facebook SDK.");
}
}
}

- (NSDictionary<NSString *, NSString *> *)constantsToExport {
Expand Down Expand Up @@ -155,7 +164,7 @@ + (void)deferInitializationForJSLoad
+ (void)initSessionWithLaunchOptions:(NSDictionary *)launchOptions isReferrable:(BOOL)isReferrable {
savedLaunchOptions = launchOptions;
savedIsReferrable = isReferrable;

[self.branch registerPluginName:@"ReactNative" version:RNBNC_PLUGIN_VERSION];

// Can't currently support this on Android.
Expand Down Expand Up @@ -498,8 +507,8 @@ - (BranchUniversalObject *)findUniversalObjectWithIdent:(NSString *)ident reject
@"completed" : @(completed),
@"error" : [NSNull null]
};
// SDK-854 do not callback more than once.

// SDK-854 do not callback more than once.
// The native iOS code calls back with status even if the user just cancelled.
if (completed) {
resolve(result);
Expand Down
2 changes: 2 additions & 0 deletions ios/RNBranchConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern NSString * _Nonnull const RNBranchConfigUseTestInstanceOption;
extern NSString * _Nonnull const RNBranchConfigDelayInitToCheckForSearchAdsOption;
extern NSString * _Nonnull const RNBranchConfigAppleSearchAdsDebugModeOption;
extern NSString * _Nonnull const RNBranchConfigDeferInitializationForJSLoadOption;
extern NSString * _Nonnull const RNBranchConfigEnableFacebookLinkCheck;

@interface RNBranchConfig : NSObject

Expand All @@ -31,6 +32,7 @@ extern NSString * _Nonnull const RNBranchConfigDeferInitializationForJSLoadOptio
@property (nonatomic, readonly) BOOL delayInitToCheckForSearchAds;
@property (nonatomic, readonly) BOOL appleSearchAdsDebugMode;
@property (nonatomic, readonly) BOOL deferInitializationForJSLoad;
@property (nonatomic, readonly) BOOL enableFacebookLinkCheck;

- (nullable id)objectForKey:(NSString * _Nonnull)key;
- (nullable id)objectForKeyedSubscript:(NSString * _Nonnull)key;
Expand Down
7 changes: 7 additions & 0 deletions ios/RNBranchConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
NSString * _Nonnull const RNBranchConfigDelayInitToCheckForSearchAdsOption = @"delayInitToCheckForSearchAds";
NSString * _Nonnull const RNBranchConfigAppleSearchAdsDebugModeOption = @"appleSearchAdsDebugMode";
NSString * _Nonnull const RNBranchConfigDeferInitializationForJSLoadOption = @"deferInitializationForJSLoad";
NSString * _Nonnull const RNBranchConfigEnableFacebookLinkCheck = @"enableFacebookLinkCheck";

NSString * const RNBNC_PLUGIN_VERSION = @"4.3.0";

Expand Down Expand Up @@ -144,6 +145,12 @@ - (BOOL)deferInitializationForJSLoad
return number.boolValue;
}

- (BOOL)enableFacebookLinkCheck
{
NSNumber *number = self[RNBranchConfigEnableFacebookLinkCheck];
return number.boolValue;
}

- (NSString *)branchKey
{
return self[RNBranchConfigBranchKeyOption];
Expand Down
22 changes: 11 additions & 11 deletions native-tests/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PODS:
- boost-for-react-native (1.63.0)
- Branch (0.27.1):
- Branch/Core (= 0.27.1)
- Branch/Core (0.27.1)
- Branch (0.31.3):
- Branch/Core (= 0.31.3)
- Branch/Core (0.31.3)
- DoubleConversion (1.1.6)
- Folly (2018.10.22.00):
- boost-for-react-native
Expand All @@ -14,7 +14,7 @@ PODS:
- DoubleConversion
- glog
- glog (0.3.5)
- OCMock (3.4.3)
- OCMock (3.6)
- React (0.60.4):
- React-Core (= 0.60.4)
- React-DevSupport (= 0.60.4)
Expand Down Expand Up @@ -61,8 +61,8 @@ PODS:
- React-cxxreact (= 0.60.4)
- React-jsi (= 0.60.4)
- React-jsinspector (0.60.4)
- react-native-branch (4.1.1):
- Branch (= 0.27.1)
- react-native-branch (4.3.0):
- Branch (= 0.31.3)
- React
- React-RCTActionSheet (0.60.4):
- React-Core (= 0.60.4)
Expand Down Expand Up @@ -117,7 +117,7 @@ DEPENDENCIES:
- yoga (from `../../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
trunk:
- boost-for-react-native
- Branch
- OCMock
Expand Down Expand Up @@ -172,11 +172,11 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
Branch: 1ace77c04b6e3efbf982bf4364f0662bfac156a0
Branch: 9b299693ee54b308ff8c18146afe1f711c2069ec
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
OCMock: 43565190abc78977ad44a61c0d20d7f0784d35ab
OCMock: 5ea90566be239f179ba766fd9fbae5885040b992
React: ff7ee2ae5ee1c1d9ae2183b4111045b25294bb01
React-Core: 8e0ea421cae5609d2562850f98421b15030476fa
React-cxxreact: 326880209990151a7182a813311054e9772ba510
Expand All @@ -185,7 +185,7 @@ SPEC CHECKSUMS:
React-jsi: 21d3153b1153fbf6510a92b6b11e33e725cb7432
React-jsiexecutor: 7549641e48bafae7bfee3f3ea19bf4901639c5de
React-jsinspector: 73f24a02fa684ed6a2b828ba116874a2191ded88
react-native-branch: d63b7eb5f71ea5c6681946f11cb8ce194a50895b
react-native-branch: df34ffd1ff1f592b42455c717e55b4b01a1d17d3
React-RCTActionSheet: 9f71d7ae3e8fb10e08d162cbf14c621349dbfab3
React-RCTAnimation: 981d8c95b0e30918a9832ccac32af83562a27fae
React-RCTBlob: 21e73d1020a302a75fed30dbaee9f15287b80baa
Expand All @@ -200,4 +200,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 93a63577b10fd56f217a28029a024519e7fb9c9d

COCOAPODS: 1.7.5
COCOAPODS: 1.8.4

0 comments on commit 02cf838

Please sign in to comment.