Skip to content

Commit

Permalink
Added networkCount reset
Browse files Browse the repository at this point in the history
  • Loading branch information
nsingh-branch committed Nov 26, 2024
1 parent 5c41177 commit 8340ee3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Branch-TestBed/Branch-TestBed/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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"];
Expand Down Expand Up @@ -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];

Expand Down
7 changes: 5 additions & 2 deletions Sources/BranchSDK/Branch.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand All @@ -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]];
});
Expand Down

0 comments on commit 8340ee3

Please sign in to comment.