Update trigger model to always drive a change event #1925
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.
Description
One Line Summary
Update trigger model to always drive a change event when changing the value. This allows IAMs to be re-evaluated even when setting a trigger to the same value.
Details
When calling
OneSignal.getInAppMessages().addTrigger(...)
the expectation is it will drive the evaluation of whether to display an IAM regardless of the trigger key/value. For v5 triggers are built on top of the model infrastructure, and evaluation is triggered when a model is changed. This means if a trigger key/value already exists, setting it to the same value would not drive IAM evaluation. This fix updates this specific case to drive IAM evaluation regardless of whether the value has changed.Motivation
v5 add trigger functionality to be identical to previous SDK behaviors.
Scope
This fix is limited to when IAMs are evaluated, specifically through calling
addTrigger
when the trigger key already exists.Testing
Manual testing
Ran the example app in an emulator, setting the same trigger key/value pair multiple times ensuring an IAM based on that trigger is displayed each time.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is