[SDK-2473] Fix for early branch init on install #1451
+12
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
When a BranchEvent is logged on first open before the SDK is initialized, we try to initialize first to log it properly. However, the SDK was reaching a state where
processNextQueueItem
was stuck and unable to process the first install or the event and nothing would happen until the next session. It seems like this was due to the BranchEvent request basically causing the queue to get stuck and the SDK to stay in an initializing state sinceprocessNextQueueItem
would be skippednetworkCount
wasn't equal to 0.This change updates the if statement to also set the networkCount to 0 which allows the install to be processed and then the event to be processed after that. Since this statement only applies to non-install or open events on the first session, this change shouldn't have an effect on other cases.
Motivation
Fix for a bug, mainly for the Adobe Branch plugin, but other clients may be trying to log events early in some cases as well.
Type Of Change
Testing Instructions
Try out the updated testbed which logs an event from the AppDelegate before the SDK is initialized.
cc @BranchMetrics/saas-sdk-devs for visibility.