Double Purchase Event with ApplePay Fix #1402
Merged
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.
Reference
INTENG-20410 - [Multiple] Purchase event being triggered twice in iOS
https://branch.atlassian.net/browse/INTENG-20410
Summary
In Event queue,
dequeue
function is replaced with- (void)remove:(BNCServerRequest *)request
function.This fix will, instead of removing first event in the queue, will remove current event from the queue.
Detailed Description
When In-App-Purchase sheet or Apple Pay sheet appears branch goes to inactive state. After payment is done,
logEvent
API is called inside the Apple/Stripe payment API callback. And then sheet is closed and app comes back to active state again. This creates two events -Following is order of events happened inside SDK:
processNextQueueItem
processNextQueueItem
. (Note: Branch Open/Install events are inserted in begining og queue)dequeue
function is called which removes the first Event in Queue. So instead of removing PurchaseEvent, OpenEvent is removed.Queue State(s)
PurchaseEvent (Waiting)
PurchaseEvent (In Processing) —> OpenEvent (Waiting)
PurchaseEvent (Finished) —> OpenEvent (Waiting)
PurchaseEvent (Finished)
PurchaseEvent (In Processing)
Fix: Instead of removing first event in the queue, current event (whose processing finished) should be removed.
Type Of Change
Testing Instructions
Use following sample app for testing.
https://github.com/BranchMetrics/InAppPurchaseAPITest
This app uses sandbox envirnoment for testing.
- Steps for creating sandbox test user account - https://developer.apple.com/help/app-store-connect/test-in-app-purchases/create-sandbox-apple-ids.
- Use above account for purchase.
Validate Following :
After you close Apple Pay Purchase Sheet,
Without Fix
--> You you will see double purchase events in logs and No open event.
With Fix
--> You you will see one purchase event and one open event in logs.
cc @BranchMetrics/saas-sdk-devs for visibility.