-
Notifications
You must be signed in to change notification settings - Fork 266
feat: IAMs now display when triggers added before first fetch #1635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fix/format_purchase_price_with_commas
Are you sure you want to change the base?
feat: IAMs now display when triggers added before first fetch #1635
Conversation
- Addresses issue where in-app messages wouldn't display on cold starts if their triggers were added very early (before IAM fetch completed). - Tracks triggers added before first fetch completes, then applies the isTriggerChanged flag to matching messages when they are received from the server, ensuring redisplay logic works correctly.
Add comprehensive test coverage for the early trigger tracking feature that enables IAMs to display when triggers are added before the first fetch completes on cold start.
6b3b1a9 to
4cd7760
Compare
| [self evaluateRedisplayedInAppMessages:triggers.allKeys]; | ||
|
|
||
| // Track triggers added early on cold start (before first fetch completes) for redisplay logic | ||
| if (!self.hasCompletedFirstFetch) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do we make sure there are no duplicates in this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we make sure this is thread safe?
| [self evaluateRedisplayedInAppMessages:triggers.allKeys]; | ||
|
|
||
| // Track triggers added early on cold start (before first fetch completes) for redisplay logic | ||
| if (!self.hasCompletedFirstFetch) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicates? Unsure what you mean, earlySessionTriggers is a set.
If clients are concurrently calling addTrigger from 2 threads, then the existing code would already be an issue?
Description
One Line Summary
Display IAMs with triggers added before first fetch on cold start.
Details
On subsequent cold starts, if triggers were added very early in the app lifecycle (before the first IAM fetch completed), in-app messages matching those triggers would not display even though they should have been eligible for redisplay.
Root cause: When the trigger is added, evaluateRedisplayedInAppMessages was called when the messages were empty, so message.isTriggerChanged was never set for messages that arrived later from the server.
Solution: Track trigger keys added before the first fetch completes in earlySessionTriggers, then apply isTriggerChanged to matching redisplay messages when they arrive from the server. This ensures the redisplay logic correctly identifies that triggers have changed and clears the message from seenInAppMessages.
Motivation
Provide feature that is requested
Scope
This only affects cold starts (process restarts) and does not impact warm starts from backgrounding, where existing redisplay behavior is preserved.
Testing
Unit testing
WIP
Manual testing
Tested on iOS 18.5 simulator
Add trigger immediately after initialization, and confirm the IAM now displays after the changes in this PR.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is