fix: [SDK-4513] display queued in-app messages on unpause when triggers still match#2682
Conversation
…rs still match Messages that qualified while paused were parked in messageDisplayQueue and only re-attempted when a later trigger change happened to re-qualify a message, so unpausing alone never resumed delivery mid-session. The unpause branch of the paused setter now prunes queue entries whose triggers no longer evaluate true (matching iOS, which never queues while paused), re-evaluates all messages, and drains the remaining queue. Fixes #2647
|
@claude review once |
📊 Diff Coverage ReportDiff Coverage Report (Changed Lines Only)Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff). Changed Files Coverage
Overall (aggregate gate)8/8 touched executable lines covered (100.0% — requires ≥ 80%) |
|
I’d address two queue-edge cases before merging:
|
|
Addressed your second point in 2f7be84: The setter now captures Regarding your first point: I generally agree but it's pre-existing behavior. The dismiss-drain path in |
|
The latest commit addresses the original unpause transition concern and adds the dismissed-message coverage I asked about. |
Description
One Line Summary
Setting
InAppMessages.paused = falsenow displays messages that were queued while paused (if their triggers still evaluate true) instead of leaving them parked until the next session.Details
Motivation
Fixes #2647 (SDK-4513). Messages that qualified while paused are added to
messageDisplayQueue, butattemptToShowInAppMessage()early-returns while paused, so they stay parked. On unpause, the setter only calledevaluateInAppMessages(), which re-attempts display only when a message currently evaluates true — unpausing alone never resumed delivery mid-session, and the queued IAM only appeared after a session boundary (30+ seconds backgrounded). This contradicts the documented behavior: "Changing the value to false resumes normal message delivery for users who qualify based on their triggers."The unpause branch now:
messagesand display as soon as their triggers qualify again.evaluateInAppMessages()), which re-queues and displays anything that currently qualifies.attemptToShowInAppMessage()).This supersedes #2671, which unconditionally drained the queue on unpause — including messages whose triggers no longer evaluated true, diverging from iOS behavior.
Scope
Only the
pausedsetter's unpause path inInAppMessagesManager. Trigger evaluation, queueing, redisplay logic, and the pause/dismiss path are unchanged. Not addressed: the reporter's secondary claim that keepingpaused = falseat all times also fails — that could not be reproduced on Android (mid-session trigger-driven display works correctly in testing) and may be Unity-bridge-specific or environmental.Testing
Unit testing
Three new tests in
InAppMessagesManagerTests.kt("Message Queue and Display" context), using a statefulInAppStateServicemock so the paused/showing state behaves like production:paused = falsefirst, trigger added second)All 67 module tests pass.
spotlessCheck,detekt, andassembleReleaseare clean.Manual testing
Tested on a Pixel 9 emulator (Android 16, ARM64, Play image) with the demo app built against this branch's SDK source (
./gradlew :app:assembleGmsDebug), using the shared demo OneSignal app (77e32082-ea27-42e3-a898-c72e141824ef) and its pre-configurediam_type-triggered IAM campaigns. Logs observed viaadb logcat -s OneSignalSDK:V.Scenario 1 — queued while paused, displays on unpause (the reported bug):
setPaused(value: true)in logs).iam_type=top_banner). Logs show the message added to the queue followed byIn app messaging is currently paused, in app messages will not be shown!— the parked state from the ticket.onWillDisplayfires, and the impression POST returns 200. Before this fix, nothing displayed until the app was backgrounded 30+ seconds.Scenario 2 — stale queued message is pruned, not displayed:
iam_type=center_modalIAM; blocked by pause).iam_typetrigger (the queued message's triggers no longer evaluate true).There are no IAMs left in the queue!(the stale entry was pruned). fix: [SDK-4513] re-display queued in-app messages on unpause #2671's approach would have wrongly displayed it here.Affected code checklist
Checklist
Overview
Testing
Final pass