Skip to content

Commit af8dbb1

Browse files
expose cpp method
1 parent 02170e5 commit af8dbb1

File tree

11 files changed

+83
-5
lines changed

11 files changed

+83
-5
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2025-02-07 Version 6.5.0
2+
- Update iOS SDK to 3.9.0
3+
- Update Android SDK to 5.15.1
4+
- Exposed new method `setConsumerProtectionAttributionLevel` to set CPP level
5+
16
2024-10-29 Version 6.4.0
27
- Update iOS SDK to 3.6.5
38
- Update Android SDK to 5.13.0

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ def safeExtGet(prop, fallback) {
4747
dependencies {
4848
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
4949
implementation 'com.facebook.react:react-native:+' // From node_modules
50-
api 'io.branch.sdk.android:library:5.12.4'
50+
api 'io.branch.sdk.android:library:5.15.1'
5151
}

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,32 @@ public void setDMAParamsForEEA(boolean eeaRegion, boolean adPersonalizationConse
12531253
branch.setDMAParamsForEEA(eeaRegion, adPersonalizationConsent, adUserDataUsageConsent);
12541254
}
12551255

1256+
@ReactMethod
1257+
public void setConsumerProtectionAttributionLevel(String level) {
1258+
Branch branch = Branch.getInstance();
1259+
BranchAttributionLevel attributionLevel;
1260+
1261+
switch (level) {
1262+
case "FULL":
1263+
attributionLevel = BranchAttributionLevel.FULL;
1264+
break;
1265+
case "REDUCED":
1266+
attributionLevel = BranchAttributionLevel.REDUCED;
1267+
break;
1268+
case "MINIMAL":
1269+
attributionLevel = BranchAttributionLevel.MINIMAL;
1270+
break;
1271+
case "NONE":
1272+
attributionLevel = BranchAttributionLevel.NONE;
1273+
break;
1274+
default:
1275+
Log.w(REACT_CLASS, "Invalid attribution level: " + level);
1276+
return;
1277+
}
1278+
1279+
branch.setConsumerProtectionAttributionLevel(attributionLevel);
1280+
}
1281+
12561282
@ReactMethod
12571283
public void validateSDKIntegration() {
12581284
IntegrationValidator.validate(mActivity);

branchreactnativetestbed/App.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ class App extends React.Component<any, MyState> {
103103
onPress: this.branchWrapper.viewLatestReferringParams.bind(this),
104104
image: require('./images/bolt_FILL0_wght400_GRAD0_opsz48.png'),
105105
},
106+
{
107+
text: 'Set Attribution Level',
108+
onPress: () => this.branchWrapper.setConsumerProtectionAttributionLevel('REDUCED'),
109+
image: require('./images/person_FILL1_wght400_GRAD0_opsz48.png'),
110+
},
106111
{
107112
text: 'Set User ID',
108113
onPress: () => this.branchWrapper.setUserIdAsync('rntest'),

branchreactnativetestbed/components/BranchWrapper.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,12 @@ export default class BranchWrapper {
209209
});
210210
};
211211

212+
setConsumerProtectionAttributionLevel = (level: 'FULL' | 'REDUCED' | 'MINIMAL' | 'NONE') => {
213+
console.log('BranchWrapper setConsumerProtectionAttributionLevel ' + level);
214+
branch.setConsumerProtectionAttributionLevel(level);
215+
this.createAlert('Attribution Level Set', `Level set to: ${level}`);
216+
};
217+
212218
toggleTracking = async () => {
213219
let trackingDisabled = await branch.isTrackingDisabled();
214220

branchreactnativetestbed/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
},
1212
"dependencies": {
1313
"react": "18.2.0",
14-
"react-native": "0.72.5",
15-
"react-native-branch": "6.4.0-alpha.0"
14+
"react-native": "0.72.9",
15+
"react-native-branch": "6.5.0-alpha.1"
1616
},
1717
"devDependencies": {
1818
"@babel/core": "^7.20.0",

ios/RNBranch.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,25 @@ - (CGFloat) colorComponentFrom: (NSString *) string start: (NSUInteger) start le
745745
[Branch setDMAParamsForEEA:eeaRegion AdPersonalizationConsent:adPersonalizationConsent AdUserDataUsageConsent:adUserDataUsageConsent];
746746
}
747747

748+
#pragma mark setConsumerProtectionAttributionLevel
749+
RCT_EXPORT_METHOD(setConsumerProtectionAttributionLevel:(NSString *)level) {
750+
BranchAttributionLevel attributionLevel;
751+
if ([level isEqualToString:@"FULL"]) {
752+
attributionLevel = BranchAttributionLevelFull;
753+
} else if ([level isEqualToString:@"REDUCED"]) {
754+
attributionLevel = BranchAttributionLevelReduced;
755+
} else if ([level isEqualToString:@"MINIMAL"]) {
756+
attributionLevel = BranchAttributionLevelMinimal;
757+
} else if ([level isEqualToString:@"NONE"]) {
758+
attributionLevel = BranchAttributionLevelNone;
759+
} else {
760+
RCTLogError(@"RNBranch::Error: Invalid attribution level: %@", level);
761+
return;
762+
}
763+
764+
[self.class.branch setConsumerProtectionAttributionLevel:attributionLevel];
765+
}
766+
748767
#pragma mark validateSDKIntegration
749768
RCT_EXPORT_METHOD(validateSDKIntegration) {
750769
[[Branch getInstance] validateSDKIntegration];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-branch",
3-
"version": "6.4.0",
3+
"version": "6.5.0-alpha.1",
44
"description": "Branch Metrics React Native SDK",
55
"main": "src/index.js",
66
"types": "src/index.d.ts",

react-native-branch.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Pod::Spec.new do |s|
2222
s.source_files = [ "ios/*.h", "ios/*.m"]
2323
s.compiler_flags = %[-DRNBRANCH_VERSION=@\\"#{s.version}\\"]
2424
s.header_dir = 'RNBranch' # also sets generated module name
25-
s.dependency 'BranchSDK', '3.6.5'
25+
s.dependency 'BranchSDK', '3.9.0'
2626
s.dependency 'React-Core' # to ensure the correct build order
2727

2828
# Swift/Objective-C compatibility

src/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export type ATTAuthorizationStatus =
5252
| 'undetermined'
5353
| 'restricted';
5454

55+
export type BranchAttributionLevel = 'FULL' | 'REDUCED' | 'MINIMAL' | 'NONE';
56+
5557
export class BranchEvent {
5658
logEvent: () => Promise<null>;
5759
constructor(
@@ -348,6 +350,7 @@ interface Branch {
348350
setPreInstallCampaign: (campaign: string) => void;
349351
setPreInstallPartner: (partner: string) => void;
350352
setDMAParamsForEEA: (eeaRegion: boolean, adPersonalizationConsent: boolean, adUserDataUsageConsent: boolean) => void;
353+
setConsumerProtectionAttributionLevel: (level: BranchAttributionLevel) => void;
351354
validateSDKIntegration: () => void;
352355
}
353356
declare const branch: Branch;

0 commit comments

Comments
 (0)