fix(ios)!: duplicate notification presentation on iOS 18.0 #303
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
In iOS 18.0, there is a known issue where the
willPresentNotification
method is triggered twice for a single payload.The
willPresentNotification
method is normally triggered when a notification is received while the app is in the foreground.Due to this bug, the notification payload is delivered twice, causing the front-end to process the notification event twice as well.
This behavior is unintended, so this PR added a block of code to check if the payload is a duplicated by comparing the payload content and the timestamp of when it was received.
Note: This block of code will only run on iOS 18.0. When testing the iOS 18.1 official release, the bug seems to be resolved.
Related Issue
Resolves #295
Motivation and Context
This PR proposes a solution to address the iOS 18.0 notification duplication bug.
The fix adds a duplicate-checking mechanism directly on the native/plugin side, so app developers won’t need to detect and handle duplicate payloads in the front-end code.
Note: An alternative approach would be to modify the plugin to pass the payload’s timestamp to the front end, allowing app developers to implement their own logic for managing duplicates if desired.
How Has This Been Tested?
4a. Confirmed that only
iOS 18.0
without the PR fix triggers the notification event twice.4b. Confirmed that only
iOS 18.0
with the PR fix to execute the new block of code and triggers the notification event once.Screenshots (if appropriate):
Types of changes
Checklist: