Skip to content
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

fix(ios)!: duplicate notification presentation on iOS 18.0 #303

Open
wants to merge 1 commit into
base: fix/notification-event
Choose a base branch
from

Conversation

erisu
Copy link

@erisu erisu commented Nov 13, 2024

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?

  1. Launched Simulators:
  • iOS 17.5
  • iOS 18.0
  • iOS 18.1
  1. Open the application in the foreground.
  2. Drop APNs payload to each simulator.
    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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@erisu erisu added this to the 5.0.0 milestone Nov 13, 2024
@erisu erisu added the ios iOS Platform label Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ios iOS Platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant