Skip to content

Commit 02cf838

Browse files
authored
Merge pull request #551 from BranchMetrics/INTENG-8649-fb-deep-linking-class
[INTENG-8649] Facebook deep linking class
2 parents 4feb8cf + 3644288 commit 02cf838

File tree

8 files changed

+54
-18
lines changed

8 files changed

+54
-18
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ android/build
4949
.idea
5050

5151
Pods
52+
53+
# for now. not such a great idea. need to sort the bundler 1.x/2.x issue here.
54+
Gemfile.lock

android/src/main/java/io/branch/rnbranch/RNBranchConfig.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,17 @@ public boolean getUseTestInstance() {
126126
return false;
127127
}
128128
}
129+
130+
public boolean getEnableFacebookLinkCheck() {
131+
if (mConfiguration == null) return false;
132+
133+
try {
134+
if (!mConfiguration.has("enableFacebookLinkCheck")) return false;
135+
return mConfiguration.getBoolean("enableFacebookLinkCheck");
136+
}
137+
catch (JSONException exception) {
138+
Log.e(TAG, "Error parsing branch.json: " + exception.getMessage());
139+
return false;
140+
}
141+
}
129142
}

android/src/main/java/io/branch/rnbranch/RNBranchModule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private void generateLocalBroadcast(JSONObject referringParams,
231231
LocalBroadcastManager.getInstance(mmActivity).sendBroadcast(broadcastIntent);
232232
}
233233
}.init(reactActivity);
234-
234+
235235
branch.initSession(referralInitListener, uri, reactActivity);
236236
}
237237

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

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

690+
if (config.getEnableFacebookLinkCheck()) branch.enableFacebookAppLinkCheck();
691+
690692
if (mRequestMetadata != null) {
691693
Iterator keys = mRequestMetadata.keys();
692694
while (keys.hasNext()) {

docs/branch.json.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ of `branch.json`.
9292
## Contents
9393

9494
Note that support for setting Branch keys on Android in branch.json requires
95-
version 3.x of react-native-branch, using [RNBranchModule.getAutoInstance()](../README.md#updating-from-an-earlier-version-or-starting-with-v300)
95+
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)
9696

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

@@ -115,6 +115,6 @@ See [branch.example.json](https://github.com/BranchMetrics/react-native-branch-d
115115
"testKey": "key_test_yyyy",
116116
"useTestInstance": true,
117117
"delayInitToCheckForSearchAds": true,
118-
"appleSearchAdsDebugMode": true
118+
"enableFacebookLinkCheck": true
119119
}
120120
```

ios/RNBranch.m

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ + (void)setupBranchInstance:(Branch *)instance
8282
if (config.delayInitToCheckForSearchAds) {
8383
[instance delayInitToCheckForSearchAds];
8484
}
85+
if (config.enableFacebookLinkCheck) {
86+
Class FBSDKAppLinkUtility = NSClassFromString(@"FBSDKAppLinkUtility");
87+
if (FBSDKAppLinkUtility) {
88+
[instance registerFacebookDeepLinkingClass:FBSDKAppLinkUtility];
89+
}
90+
else {
91+
RCTLogWarn(@"FBSDKAppLinkUtility not found but enableFacebookLinkCheck set to true. Please be sure you have integrated the Facebook SDK.");
92+
}
93+
}
8594
}
8695

8796
- (NSDictionary<NSString *, NSString *> *)constantsToExport {
@@ -155,7 +164,7 @@ + (void)deferInitializationForJSLoad
155164
+ (void)initSessionWithLaunchOptions:(NSDictionary *)launchOptions isReferrable:(BOOL)isReferrable {
156165
savedLaunchOptions = launchOptions;
157166
savedIsReferrable = isReferrable;
158-
167+
159168
[self.branch registerPluginName:@"ReactNative" version:RNBNC_PLUGIN_VERSION];
160169

161170
// Can't currently support this on Android.
@@ -498,8 +507,8 @@ - (BranchUniversalObject *)findUniversalObjectWithIdent:(NSString *)ident reject
498507
@"completed" : @(completed),
499508
@"error" : [NSNull null]
500509
};
501-
502-
// SDK-854 do not callback more than once.
510+
511+
// SDK-854 do not callback more than once.
503512
// The native iOS code calls back with status even if the user just cancelled.
504513
if (completed) {
505514
resolve(result);

ios/RNBranchConfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extern NSString * _Nonnull const RNBranchConfigUseTestInstanceOption;
1818
extern NSString * _Nonnull const RNBranchConfigDelayInitToCheckForSearchAdsOption;
1919
extern NSString * _Nonnull const RNBranchConfigAppleSearchAdsDebugModeOption;
2020
extern NSString * _Nonnull const RNBranchConfigDeferInitializationForJSLoadOption;
21+
extern NSString * _Nonnull const RNBranchConfigEnableFacebookLinkCheck;
2122

2223
@interface RNBranchConfig : NSObject
2324

@@ -31,6 +32,7 @@ extern NSString * _Nonnull const RNBranchConfigDeferInitializationForJSLoadOptio
3132
@property (nonatomic, readonly) BOOL delayInitToCheckForSearchAds;
3233
@property (nonatomic, readonly) BOOL appleSearchAdsDebugMode;
3334
@property (nonatomic, readonly) BOOL deferInitializationForJSLoad;
35+
@property (nonatomic, readonly) BOOL enableFacebookLinkCheck;
3436

3537
- (nullable id)objectForKey:(NSString * _Nonnull)key;
3638
- (nullable id)objectForKeyedSubscript:(NSString * _Nonnull)key;

ios/RNBranchConfig.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
NSString * _Nonnull const RNBranchConfigDelayInitToCheckForSearchAdsOption = @"delayInitToCheckForSearchAds";
1919
NSString * _Nonnull const RNBranchConfigAppleSearchAdsDebugModeOption = @"appleSearchAdsDebugMode";
2020
NSString * _Nonnull const RNBranchConfigDeferInitializationForJSLoadOption = @"deferInitializationForJSLoad";
21+
NSString * _Nonnull const RNBranchConfigEnableFacebookLinkCheck = @"enableFacebookLinkCheck";
2122

2223
NSString * const RNBNC_PLUGIN_VERSION = @"4.3.0";
2324

@@ -144,6 +145,12 @@ - (BOOL)deferInitializationForJSLoad
144145
return number.boolValue;
145146
}
146147

148+
- (BOOL)enableFacebookLinkCheck
149+
{
150+
NSNumber *number = self[RNBranchConfigEnableFacebookLinkCheck];
151+
return number.boolValue;
152+
}
153+
147154
- (NSString *)branchKey
148155
{
149156
return self[RNBranchConfigBranchKeyOption];

native-tests/ios/Podfile.lock

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PODS:
22
- boost-for-react-native (1.63.0)
3-
- Branch (0.27.1):
4-
- Branch/Core (= 0.27.1)
5-
- Branch/Core (0.27.1)
3+
- Branch (0.31.3):
4+
- Branch/Core (= 0.31.3)
5+
- Branch/Core (0.31.3)
66
- DoubleConversion (1.1.6)
77
- Folly (2018.10.22.00):
88
- boost-for-react-native
@@ -14,7 +14,7 @@ PODS:
1414
- DoubleConversion
1515
- glog
1616
- glog (0.3.5)
17-
- OCMock (3.4.3)
17+
- OCMock (3.6)
1818
- React (0.60.4):
1919
- React-Core (= 0.60.4)
2020
- React-DevSupport (= 0.60.4)
@@ -61,8 +61,8 @@ PODS:
6161
- React-cxxreact (= 0.60.4)
6262
- React-jsi (= 0.60.4)
6363
- React-jsinspector (0.60.4)
64-
- react-native-branch (4.1.1):
65-
- Branch (= 0.27.1)
64+
- react-native-branch (4.3.0):
65+
- Branch (= 0.31.3)
6666
- React
6767
- React-RCTActionSheet (0.60.4):
6868
- React-Core (= 0.60.4)
@@ -117,7 +117,7 @@ DEPENDENCIES:
117117
- yoga (from `../../node_modules/react-native/ReactCommon/yoga`)
118118

119119
SPEC REPOS:
120-
https://github.com/cocoapods/specs.git:
120+
trunk:
121121
- boost-for-react-native
122122
- Branch
123123
- OCMock
@@ -172,11 +172,11 @@ EXTERNAL SOURCES:
172172

173173
SPEC CHECKSUMS:
174174
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
175-
Branch: 1ace77c04b6e3efbf982bf4364f0662bfac156a0
175+
Branch: 9b299693ee54b308ff8c18146afe1f711c2069ec
176176
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
177177
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
178178
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
179-
OCMock: 43565190abc78977ad44a61c0d20d7f0784d35ab
179+
OCMock: 5ea90566be239f179ba766fd9fbae5885040b992
180180
React: ff7ee2ae5ee1c1d9ae2183b4111045b25294bb01
181181
React-Core: 8e0ea421cae5609d2562850f98421b15030476fa
182182
React-cxxreact: 326880209990151a7182a813311054e9772ba510
@@ -185,7 +185,7 @@ SPEC CHECKSUMS:
185185
React-jsi: 21d3153b1153fbf6510a92b6b11e33e725cb7432
186186
React-jsiexecutor: 7549641e48bafae7bfee3f3ea19bf4901639c5de
187187
React-jsinspector: 73f24a02fa684ed6a2b828ba116874a2191ded88
188-
react-native-branch: d63b7eb5f71ea5c6681946f11cb8ce194a50895b
188+
react-native-branch: df34ffd1ff1f592b42455c717e55b4b01a1d17d3
189189
React-RCTActionSheet: 9f71d7ae3e8fb10e08d162cbf14c621349dbfab3
190190
React-RCTAnimation: 981d8c95b0e30918a9832ccac32af83562a27fae
191191
React-RCTBlob: 21e73d1020a302a75fed30dbaee9f15287b80baa
@@ -200,4 +200,4 @@ SPEC CHECKSUMS:
200200

201201
PODFILE CHECKSUM: 93a63577b10fd56f217a28029a024519e7fb9c9d
202202

203-
COCOAPODS: 1.7.5
203+
COCOAPODS: 1.8.4

0 commit comments

Comments
 (0)