Skip to content

Commit 08e8940

Browse files
authored
Merge pull request #1254 from BranchMetrics/SDK-1932
[SDK-1932][minor] Remove auto-logging for in-app purchases as Branch Events
2 parents 6f14722 + e760484 commit 08e8940

File tree

6 files changed

+3
-73
lines changed

6 files changed

+3
-73
lines changed

Branch-TestBed/Branch-TestBed/AppDelegate.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ - (BOOL)application:(UIApplication *)application
5858

5959
[self setLogFile:@"OpenNInstall"];
6060
// [branch setIdentity:@"Bobby Branch"];
61-
62-
[Branch setLogInAppPurchasesAsEventsEnabled:true];
63-
61+
6462
[branch initSessionWithLaunchOptions:launchOptions
6563
andRegisterDeepLinkHandlerUsingBranchUniversalObject:
6664
^ (BranchUniversalObject * _Nullable universalObject, BranchLinkProperties * _Nullable linkProperties, NSError * _Nullable error) {

BranchSDK/BNCPreferenceHelper.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void);
7777
@property (assign, nonatomic) NSInteger highestConversionValueSent;
7878
@property (strong, nonatomic) NSDate *firstAppLaunchTime;
7979
@property (assign, nonatomic) BOOL invokeRegisterApp;
80-
@property (assign, nonatomic) BOOL logInAppPurchasesAsBranchEvents;
8180

8281
- (void) clearTrackingInformation;
8382

BranchSDK/BNCPreferenceHelper.m

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ @implementation BNCPreferenceHelper
109109
skanCurrentWindow = _skanCurrentWindow,
110110
firstAppLaunchTime = _firstAppLaunchTime,
111111
highestConversionValueSent = _highestConversionValueSent,
112-
logInAppPurchasesAsBranchEvents = _logInAppPurchasesAsBranchEvents,
113112
referringURLQueryParameters = _referringURLQueryParameters,
114113
anonID = _anonID,
115114
patternListURL = _patternListURL;
@@ -815,16 +814,6 @@ - (void) setInvokeRegisterApp:(BOOL)invoke {
815814
}
816815
}
817816

818-
- (BOOL) logInAppPurchasesAsBranchEvents {
819-
_logInAppPurchasesAsBranchEvents = [self readBoolFromDefaults:BRANCH_PREFS_KEY_LOG_IAP_AS_EVENTS];
820-
return _logInAppPurchasesAsBranchEvents;
821-
}
822-
823-
- (void) setLogInAppPurchasesAsBranchEvents:(BOOL)logInAppPurchasesAsBranchEvents {
824-
_logInAppPurchasesAsBranchEvents = logInAppPurchasesAsBranchEvents;
825-
[self writeBoolToDefaults:BRANCH_PREFS_KEY_LOG_IAP_AS_EVENTS value:logInAppPurchasesAsBranchEvents];
826-
}
827-
828817
- (void) clearTrackingInformation {
829818
@synchronized(self) {
830819
/*

BranchSDK/Branch.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,9 +1856,6 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
18561856
- (void)passPasteItemProviders:(NSArray<NSItemProvider *> *)itemProviders API_AVAILABLE(ios(16));
18571857
#endif
18581858

1859-
+ (void)setLogInAppPurchasesAsEventsEnabled:(BOOL)enabled;
1860-
+ (BOOL)logInAppPurchasesBranchEventsEnabled;
1861-
18621859
@end
18631860

18641861
NS_ASSUME_NONNULL_END

BranchSDK/Branch.m

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
#import "NSError+Branch.h"
4747
#import "BNCLog.h"
4848
#import "UIViewController+Branch.h"
49-
#import <StoreKit/StoreKit.h>
5049
#import "BNCReferringURLUtility.h"
5150

5251
#if !TARGET_OS_TV
@@ -125,7 +124,7 @@ typedef NS_ENUM(NSInteger, BNCInitStatus) {
125124
BNCInitStatusInitialized
126125
};
127126

128-
@interface Branch() <BranchDeepLinkingControllerCompletionDelegate, SKPaymentTransactionObserver> {
127+
@interface Branch() <BranchDeepLinkingControllerCompletionDelegate> {
129128
NSInteger _networkCount;
130129
BNCURLFilter *_userURLFilter;
131130
}
@@ -1641,10 +1640,6 @@ + (Branch *)getInstanceInternal:(NSString *)key {
16411640
cache:[[BNCLinkCache alloc] init]
16421641
preferenceHelper:preferenceHelper
16431642
key:key];
1644-
1645-
if ([BNCPreferenceHelper sharedInstance].logInAppPurchasesAsBranchEvents == YES) {
1646-
[[SKPaymentQueue defaultQueue] addTransactionObserver:branch];
1647-
}
16481643
});
16491644
return branch;
16501645
}
@@ -2566,51 +2561,4 @@ + (void) clearAll {
25662561
[BNCPreferenceHelper clearAll];
25672562
}
25682563

2569-
#pragma mark - SKPaymentTransactionObserver Methods
2570-
+ (void)setLogInAppPurchasesAsEventsEnabled:(BOOL)enabled {
2571-
@synchronized(self) {
2572-
if (enabled) {
2573-
[BNCPreferenceHelper sharedInstance].logInAppPurchasesAsBranchEvents = YES;
2574-
} else {
2575-
[BNCPreferenceHelper sharedInstance].logInAppPurchasesAsBranchEvents = NO;
2576-
}
2577-
}
2578-
}
2579-
2580-
+ (BOOL)logInAppPurchasesBranchEventsEnabled {
2581-
@synchronized(self) {
2582-
return [BNCPreferenceHelper sharedInstance].logInAppPurchasesAsBranchEvents;
2583-
}
2584-
}
2585-
2586-
//Logs incoming in-app purchases as events
2587-
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray<SKPaymentTransaction *> *)transactions {
2588-
for (SKPaymentTransaction *transaction in transactions) {
2589-
switch (transaction.transactionState) {
2590-
case SKPaymentTransactionStatePurchased: {
2591-
2592-
[[SKPaymentQueue defaultQueue] finishTransaction:(SKPaymentTransaction *)transaction];
2593-
2594-
if ([BNCPreferenceHelper sharedInstance].logInAppPurchasesAsBranchEvents == YES) {
2595-
BNCLogDebug([NSString stringWithFormat:@"Automatically logging transaction as Branch event."]);
2596-
2597-
BranchEvent *event = [BranchEvent standardEvent:BranchStandardEventPurchase];
2598-
[event logEventWithTransaction:transaction];
2599-
}
2600-
break;
2601-
}
2602-
case SKPaymentTransactionStateFailed: {
2603-
[[SKPaymentQueue defaultQueue] finishTransaction:(SKPaymentTransaction *)transaction];
2604-
break;
2605-
}
2606-
case SKPaymentTransactionStateRestored: {
2607-
[[SKPaymentQueue defaultQueue] finishTransaction:(SKPaymentTransaction *)transaction];
2608-
break;
2609-
}
2610-
default:
2611-
break;
2612-
}
2613-
}
2614-
}
2615-
26162564
@end

BranchSDK/BranchEvent.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,9 @@ - (NSString*_Nonnull) description {
372372
#pragma mark - IAP Methods
373373

374374
- (void) logEventWithTransaction:(SKPaymentTransaction *)transaction {
375-
376375
self.transactionID = transaction.transactionIdentifier;
377376
[[BNCEventUtils shared] storeEvent:self];
378-
377+
379378
NSString *productId = transaction.payment.productIdentifier;
380379
SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:productId]];
381380

0 commit comments

Comments
 (0)