Analytics: Fixes an issue with applicationOpenedTime being reset. #10556
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.
This PR addresses an issue with the
applicationOpenedTimeproperty being reset with a new date due toUIApplicationDidBecomeActiveNotificationnotifications received while multitasking or viewing a system overlay.For more background see p9OQAC-90-p2.
To test:
trackApplicationOpenedandtrackApplicationClosed.Scenario 1:
Launch the app and confirm that
trackApplicationOpenedis called and the date is correctly set.Background the app and confirm that
trackApplicationClosedis called and the date is unset.Scenario 2:
With the app in the foreground, swipe down from the top left or right corners to view Mission Control or Notification Center. Note that
UIApplicationDidEnterBackgroundNotificationis not dispatched andtrackApplicationClosedis not called (interestinglyUIApplicationDidBecomeActiveNotificationis for some reason 🤔). Dismiss the system overlay and confirm that whiletrackApplicationOpenedis called the date is not nil and is therefore not reset.Scenario 3
Swipe up to view the launch bar. Tap and hold on another app to multitask.
Observe that
UIApplicationDidBecomeActiveNotificationis dispatched when multitasking starts. Adjust the split screen and observe thatUIApplicationDidBecomeActiveNotificationis again dispatched.In both cases confirm that confirm that while
trackApplicationOpenedis called the date is not nil and is therefore not reset.@jklausa could I trouble you for a review?