From 8340ee3b1eb523e662b4237206b5833ec65e9c82 Mon Sep 17 00:00:00 2001 From: nsingh-branch Date: Tue, 26 Nov 2024 12:43:28 -0500 Subject: [PATCH] Added networkCount reset --- Branch-TestBed/Branch-TestBed/AppDelegate.m | 8 +++++++- Sources/BranchSDK/Branch.m | 7 +++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Branch-TestBed/Branch-TestBed/AppDelegate.m b/Branch-TestBed/Branch-TestBed/AppDelegate.m index aedf3557b..7063d22c7 100644 --- a/Branch-TestBed/Branch-TestBed/AppDelegate.m +++ b/Branch-TestBed/Branch-TestBed/AppDelegate.m @@ -12,6 +12,7 @@ #import "ViewController.h" #import "Branch.h" #import "BNCEncodingUtils.h" +#import "BranchEvent.h" AppDelegate* appDelegate = nil; void APPLogHookFunction(NSDate*_Nonnull timestamp, BranchLogLevel level, NSString*_Nullable message); @@ -33,7 +34,6 @@ - (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"]; @@ -81,6 +81,12 @@ - (BOOL)application:(UIApplication *)application [self handleDeepLinkObject:universalObject linkProperties:linkProperties error:error]; }]; + + BranchEvent *earlyEvent = [BranchEvent standardEvent:BNCAddToCartEvent]; + NSLog(@"Logging Early Event: %@", earlyEvent); + [earlyEvent logEvent]; + + // Push notification support (Optional) // [self registerForPushNotifications:application]; diff --git a/Sources/BranchSDK/Branch.m b/Sources/BranchSDK/Branch.m index f1178f45c..f91964427 100644 --- a/Sources/BranchSDK/Branch.m +++ b/Sources/BranchSDK/Branch.m @@ -1908,7 +1908,9 @@ - (BOOL)isReplayableRequest:(BNCServerRequest *)request { - (void)processNextQueueItem { dispatch_semaphore_wait(self.processing_sema, DISPATCH_TIME_FOREVER); - + + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Processing next queue item. Network Count: %ld. Queue depth: %ld", (long)self.networkCount, (long)self.requestQueue.queueDepth] error:nil]; + if (self.networkCount == 0 && self.requestQueue.queueDepth > 0) { @@ -1920,10 +1922,11 @@ - (void)processNextQueueItem { if (req) { - // If tracking is disabled, then do not check for install event. It won't exist. + // If tracking is disabled, then do not check for install event. It won't exist. if (!Branch.trackingDisabled) { if (![req isKindOfClass:[BranchInstallRequest class]] && !self.preferenceHelper.randomizedBundleToken) { [[BranchLogger shared] logError:@"User session has not been initialized!" error:nil]; + self.networkCount = 0; BNCPerformBlockOnMainThreadSync(^{ [req processResponse:nil error:[NSError branchErrorWithCode:BNCInitError]]; });