Skip to content

Commit

Permalink
Updated SKAN calls
Browse files Browse the repository at this point in the history
  • Loading branch information
nsingh-branch committed Nov 11, 2024
1 parent f432e47 commit 6392c7a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Sources/BranchSDK/BNCSKAdNetwork.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "BNCPreferenceHelper.h"
#import "BranchConstants.h"
#import "BranchLogger.h"
#import "Branch.h"

@interface BNCSKAdNetwork()

Expand Down Expand Up @@ -72,6 +73,11 @@ - (BOOL)shouldAttemptSKAdNetworkCallout {

- (void)registerAppForAdNetworkAttribution {
if (@available(iOS 14.0, macCatalyst 14.0, *)) {
if (![self isSKANAllowedForAttributionLevel]) {
[[BranchLogger shared] logDebug:@"SKAN registerAppForAdNetworkAttribution skipped due to BranchAttributionLevel" error:nil];
return;
}

if ([self shouldAttemptSKAdNetworkCallout] && [self.skAdNetworkClass respondsToSelector:self.skAdNetworkRegisterAppForAdNetworkAttribution]) {
[[BranchLogger shared] logDebug:@"Calling registerAppForAdNetworkAttribution" error:nil];
// Equivalent call [SKAdNetwork registerAppForAdNetworkAttribution];
Expand All @@ -82,6 +88,11 @@ - (void)registerAppForAdNetworkAttribution {

- (void)updateConversionValue:(NSInteger)conversionValue {
if (@available(iOS 14.0, macCatalyst 14.0, *)) {
if (![self isSKANAllowedForAttributionLevel]) {
[[BranchLogger shared] logDebug:@"SKAN updateConversionValue skipped due to BranchAttributionLevel" error:nil];
return;
}

if ([self shouldAttemptSKAdNetworkCallout] && [self.skAdNetworkClass respondsToSelector:self.skAdNetworkUpdateConversionValue]) {
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Calling updateConversionValue:%ld", (long)conversionValue] error:nil];

Expand All @@ -93,6 +104,11 @@ - (void)updateConversionValue:(NSInteger)conversionValue {

- (void)updatePostbackConversionValue:(NSInteger)conversionValue completionHandler:(void (^)(NSError *error))completion {
if (@available(iOS 15.4, macCatalyst 15.4, *)) {
if (![self isSKANAllowedForAttributionLevel]) {
[[BranchLogger shared] logDebug:@"SKAN updatePostbackConversionValue skipped due to BranchAttributionLevel" error:nil];
return;
}

if ([self shouldAttemptSKAdNetworkCallout] && [self.skAdNetworkClass respondsToSelector:self.skAdNetworkUpdatePostbackConversionValue]) {
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Calling updatePostbackConversionValue:%ld completionHandler:completion", (long)conversionValue] error:nil];

Expand All @@ -108,6 +124,11 @@ - (void)updatePostbackConversionValue:(NSInteger)fineValue
lockWindow:(BOOL)lockWindow
completionHandler:(void (^)(NSError *error))completion {
if (@available(iOS 16.1, macCatalyst 16.1, *)) {
if (![self isSKANAllowedForAttributionLevel]) {
[[BranchLogger shared] logDebug:@"SKAN updatePostbackConversionValue skipped due to BranchAttributionLevel" error:nil];
return;
}

if ([self shouldAttemptSKAdNetworkCallout] && [self.skAdNetworkClass respondsToSelector:self.skAdNetworkUpdatePostbackConversionValueCoarseValueLockWindow]) {
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Calling updatePostbackConversionValue:%ld coarseValue:%@ lockWindow:%d completionHandler:completion", (long)fineValue, coarseValue, lockWindow] error:nil];
// Equivalent call [SKAdNetwork updatePostbackConversionValue:coarseValue:lockWindow:completionHandler:];
Expand Down Expand Up @@ -197,4 +218,9 @@ - (BOOL) shouldCallPostbackForDataResponse:(NSDictionary *) dataResponseDictiona
return shouldCallUpdatePostback;
}

- (BOOL)isSKANAllowedForAttributionLevel {
BranchAttributionLevel level = [[BNCPreferenceHelper sharedInstance] attributionLevel];
return !(level == BranchAttributionLevelMinimal || level == BranchAttributionLevelNone);
}

@end

0 comments on commit 6392c7a

Please sign in to comment.