Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-2458] Implement Consumer Protection Preferences #1407

Merged
merged 20 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/automation-trigger-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: BranchMetrics/qentelli-saas-sdk-testing-automation
ref: SDK-2465
token: ${{ secrets.BRANCHLET_ACCESS_TOKEN_PUBLIC }}
- name: Set up JDK 11
uses: actions/setup-java@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ fastlane/test_output
# Ruby stuff
vendor
.bundle
DeepLinkDemo/DeepLinkDemo.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
21 changes: 21 additions & 0 deletions Branch-TestBed/Branch-SDK-Tests/BranchClassTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,25 @@ - (void)testSetDMAParamsForEEA {
[[BNCPreferenceHelper sharedInstance] writeObjectToDefaults:@"bnc_dma_ad_user_data" value:nil];
}

- (void)testSetConsumerProtectionAttributionLevel {
// Set to Reduced and check
Branch *branch = [Branch getInstance];
[branch setConsumerProtectionAttributionLevel:BranchAttributionLevelReduced];
XCTAssertEqual([BNCPreferenceHelper sharedInstance].attributionLevel, BranchAttributionLevelReduced);

// Set to Minimal and check
[branch setConsumerProtectionAttributionLevel:BranchAttributionLevelMinimal];
XCTAssertEqual([BNCPreferenceHelper sharedInstance].attributionLevel, BranchAttributionLevelMinimal);

// Set to None and check
[branch setConsumerProtectionAttributionLevel:BranchAttributionLevelNone];
XCTAssertEqual([BNCPreferenceHelper sharedInstance].attributionLevel, BranchAttributionLevelNone);

// Set to Full and check
[branch setConsumerProtectionAttributionLevel:BranchAttributionLevelFull];
XCTAssertEqual([BNCPreferenceHelper sharedInstance].attributionLevel, BranchAttributionLevelFull);

}


@end
8 changes: 7 additions & 1 deletion Branch-TestBed/Branch-TestBed/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ - (BOOL)application:(UIApplication *)application
// Branch.useTestBranchKey = YES; // Make sure to comment this line out for production apps!!!
Branch *branch = [Branch getInstance];


// Change the Branch base API URL
//[Branch setAPIUrl:@"https://api3.branch.io"];

// test pre init support
//[self testDispatchToIsolationQueue:branch]
[branch enableLoggingAtLevel:BranchLogLevelVerbose withCallback:^(NSString * _Nonnull message, BranchLogLevel logLevel, NSError * _Nullable error) {


[Branch enableLoggingAtLevel:BranchLogLevelVerbose withCallback:^(NSString * _Nonnull message, BranchLogLevel logLevel, NSError * _Nullable error) {
// Handle the log message and error here. For example, printing to the console:
if (error) {
NSLog(@"[BranchLog] Level: %lu, Message: %@, Error: %@", (unsigned long)logLevel, message, error.localizedDescription);
Expand All @@ -46,6 +49,7 @@ - (BOOL)application:(UIApplication *)application
}
}];


// Comment out in production. Un-comment to test your Branch SDK Integration:
//[branch validateSDKIntegration];

Expand All @@ -62,6 +66,8 @@ - (BOOL)application:(UIApplication *)application

[branch setIdentity:@"Bobby Branch"];

//[branch setConsumerProtectionAttributionLevel:BranchAttributionLevelReduced];

[branch initSessionWithLaunchOptions:launchOptions andRegisterDeepLinkHandlerUsingBranchUniversalObject:
^ (BranchUniversalObject * _Nullable universalObject, BranchLinkProperties * _Nullable linkProperties, NSError * _Nullable error) {

Expand Down
62 changes: 46 additions & 16 deletions Branch-TestBed/Branch-TestBed/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="rgL-wI-yV3">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="rgL-wI-yV3">
<device id="retina4_7" orientation="portrait" appearance="dark"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -21,7 +21,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BRw-ws-ocH">
<rect key="frame" x="16" y="209" width="343" height="70"/>
<rect key="frame" x="16" y="229" width="343" height="70"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="BranchPasteControl" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AHy-Uo-zAF">
<rect key="frame" x="20" y="25" width="156.5" height="20.5"/>
Expand Down Expand Up @@ -52,7 +52,7 @@
</userDefinedRuntimeAttributes>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="g5q-Nq-dCK">
<rect key="frame" x="16" y="314" width="343" height="50"/>
<rect key="frame" x="16" y="334" width="343" height="50"/>
<color key="backgroundColor" systemColor="secondarySystemBackgroundColor"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="THd-Hg-6zt"/>
Expand All @@ -72,7 +72,7 @@
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YUK-Md-9s5">
<rect key="frame" x="16" y="104" width="343" height="70"/>
<rect key="frame" x="16" y="124" width="343" height="70"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nX6-RK-9an">
<rect key="frame" x="183" y="17.5" width="140" height="35"/>
Expand Down Expand Up @@ -139,7 +139,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="MTE-X3-ym1" userLabel="logOutputTextView">
<rect key="frame" x="26" y="96" width="323" height="561"/>
<rect key="frame" x="26" y="116" width="323" height="541"/>
<color key="backgroundColor" systemColor="secondarySystemBackgroundColor"/>
<accessibility key="accessibilityConfiguration" label="DeepLinkData"/>
<color key="textColor" systemColor="labelColor"/>
Expand Down Expand Up @@ -804,6 +804,35 @@
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="4YV-Fs-BuA">
<rect key="frame" x="16" y="1174" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="4YV-Fs-BuA" id="93g-I9-9tZ">
<rect key="frame" x="0.0" y="0.0" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="leading" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oFC-oS-hU2">
<rect key="frame" x="0.0" y="0.0" width="343" height="44"/>
<accessibility key="accessibilityConfiguration" identifier="tracking"/>
<inset key="titleEdgeInsets" minX="30" minY="0.0" maxX="0.0" maxY="0.0"/>
<inset key="imageEdgeInsets" minX="20" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Consumer Protection Preference" image="checkmark.shield" catalog="system">
<color key="titleColor" systemColor="linkColor"/>
</state>
<connections>
<action selector="changeConsumerProtectionAttributionLevel:" destination="i3m-ex-Bu1" eventType="touchUpInside" id="eif-fe-3JM"/>
<action selector="goToPasteControlPressed:" destination="i3m-ex-Bu1" eventType="touchUpInside" id="oct-dQ-HLq"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="oFC-oS-hU2" secondAttribute="trailing" id="0NH-TC-sgu"/>
<constraint firstAttribute="bottom" secondItem="oFC-oS-hU2" secondAttribute="bottom" id="CKb-dX-4SM"/>
<constraint firstItem="oFC-oS-hU2" firstAttribute="top" secondItem="93g-I9-9tZ" secondAttribute="top" id="e2p-AN-GfI"/>
<constraint firstItem="oFC-oS-hU2" firstAttribute="leading" secondItem="93g-I9-9tZ" secondAttribute="leading" id="pTf-ET-lY1"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
Expand Down Expand Up @@ -832,7 +861,7 @@
<toolbarItems/>
<navigationItem key="navigationItem" title="Branch-TestBed" largeTitleDisplayMode="always" id="jbD-iI-XzT"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" largeTitles="YES" id="6au-j1-SUM">
<rect key="frame" x="0.0" y="0.0" width="375" height="96"/>
<rect key="frame" x="0.0" y="20" width="375" height="96"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
Expand All @@ -848,36 +877,37 @@
<resources>
<image name="arrow.up.right.square" catalog="system" width="128" height="114"/>
<image name="bag" catalog="system" width="128" height="128"/>
<image name="checkmark.shield" catalog="system" width="128" height="119"/>
<image name="doc.text" catalog="system" width="115" height="128"/>
<image name="doc.viewfinder.fill" catalog="system" width="128" height="115"/>
<image name="eye" catalog="system" width="128" height="79"/>
<image name="folder.badge.plus" catalog="system" width="128" height="92"/>
<image name="folder.badge.plus" catalog="system" width="128" height="93"/>
<image name="light.beacon.max" catalog="system" width="128" height="102"/>
<image name="link" catalog="system" width="128" height="124"/>
<image name="moonphase.first.quarter" catalog="system" width="128" height="123"/>
<image name="moonphase.first.quarter.inverse" catalog="system" width="128" height="123"/>
<image name="person" catalog="system" width="128" height="121"/>
<image name="photo.artframe" catalog="system" width="128" height="93"/>
<image name="qrcode" catalog="system" width="128" height="114"/>
<image name="rectangle.and.paperclip" catalog="system" width="128" height="98"/>
<image name="rectangle.portrait.and.arrow.right" catalog="system" width="128" height="109"/>
<image name="square.and.arrow.up" catalog="system" width="115" height="128"/>
<image name="square.and.arrow.up.on.square" catalog="system" width="119" height="128"/>
<image name="rectangle.and.paperclip" catalog="system" width="128" height="108"/>
<image name="rectangle.portrait.and.arrow.right" catalog="system" width="128" height="108"/>
<image name="square.and.arrow.up" catalog="system" width="108" height="128"/>
<image name="square.and.arrow.up.on.square" catalog="system" width="113" height="128"/>
<image name="trophy" catalog="system" width="128" height="128"/>
<systemColor name="labelColor">
<color red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="linkColor">
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="secondarySystemBackgroundColor">
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.94901960780000005" green="0.94901960780000005" blue="0.96862745100000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemGray6Color">
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.94901960780000005" green="0.94901960780000005" blue="0.96862745100000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
31 changes: 31 additions & 0 deletions Branch-TestBed/Branch-TestBed/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,37 @@ - (IBAction)goToPasteControlPressed:(id)sender {
sender:self];
}

- (IBAction)changeConsumerProtectionAttributionLevel:(id)sender {
Branch *branch = [Branch getInstance];
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"Select Consumer Protection Attribution Level" message:nil preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *fullAction = [UIAlertAction actionWithTitle:@"Full" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[branch setConsumerProtectionAttributionLevel:BranchAttributionLevelFull];
}];

UIAlertAction *privacyOnlyAction = [UIAlertAction actionWithTitle:@"Reduced" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[branch setConsumerProtectionAttributionLevel:BranchAttributionLevelReduced];
}];

UIAlertAction *attributionOnlyAction = [UIAlertAction actionWithTitle:@"Minimal" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[branch setConsumerProtectionAttributionLevel:BranchAttributionLevelMinimal];
}];

UIAlertAction *noAttributionAction = [UIAlertAction actionWithTitle:@"None" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[branch setConsumerProtectionAttributionLevel:BranchAttributionLevelNone];
}];

UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];

[actionSheet addAction:fullAction];
[actionSheet addAction:privacyOnlyAction];
[actionSheet addAction:attributionOnlyAction];
[actionSheet addAction:noAttributionAction];
[actionSheet addAction:cancelAction];

[self presentViewController:actionSheet animated:YES completion:nil];
}

-(IBAction)showVersionAlert:(id)sender {
NSString *versionString = [NSString stringWithFormat:@"Branch SDK v%@\nBundle Version %@\niOS %@",
BNC_SDK_VERSION,
Expand Down
2 changes: 0 additions & 2 deletions DeepLinkDemo/DeepLinkDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
B7B7DC292859974E00D45FC5 /* TextViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextViewController.swift; sourceTree = "<group>"; };
C06885D21868B25319262FC1 /* Pods-DeepLinkDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DeepLinkDemo.debug.xcconfig"; path = "Target Support Files/Pods-DeepLinkDemo/Pods-DeepLinkDemo.debug.xcconfig"; sourceTree = "<group>"; };
DDBB5A837B0C008CA5BEC1EF /* Pods_DeepLinkDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DeepLinkDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; };
E70E80C12A0E22C1008007B6 /* BranchSDK.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = BranchSDK.xcframework; path = Framework/BranchSDK.xcframework; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -101,7 +100,6 @@
29D53CAAE9E9EF2F96296086 /* Frameworks */ = {
isa = PBXGroup;
children = (
E70E80C12A0E22C1008007B6 /* BranchSDK.xcframework */,
DDBB5A837B0C008CA5BEC1EF /* Pods_DeepLinkDemo.framework */,
);
name = Frameworks;
Expand Down
Loading
Loading