Properly handle in-app messages dismissed by back press #2328
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.
Description
One Line Summary
Properly handle and dismiss in-app messages that are dismissed by back press.
Details
Motivation
Fixes poor behavior: When back button is pressed, the system automatically dismisses the in-app message, without the SDK's awareness. This leads to poor user experience as the SDK does not know of this message's dismissal and will inappropriately redisplay it.
Scope
InAppMessageView
. A single instance ofInAppMessageView
can have multiple popupWindow instances such as when orientation changes. So, we need to hook into individual popup windows instead of the View. We mark the popup window as manually dismissed in the methodremoveAllViews()
. This is sufficient as this method is called by every flow in the SDK that dismisses an IAM (clicking to close, activity change, drag to dismiss, etc). In our listener, if we believe the popup window was dismissed by the system bypassing OneSignal, we triggermessageController?.onMessageWasDismissed()
. This call is appropriate as this is the root method that triggers the post-dismissal flows for an IAM. We considered doing more logic in the dismiss event but we cannot generalize here as some dismiss events should not trigger the post-dismissal flow, such as on orientation changes.Example of system triggering popup window dismissal
Testing
Unit testing
None
Manual testing
Android emulator API 33
Types of IAMs tested:
Scenarios tested:
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is