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

iOS 18 calling the push handler twice when the app is in foreground #295

Open
igorsantos07 opened this issue Oct 22, 2024 · 3 comments
Open
Labels
bug Something isn't working ios iOS Platform
Milestone

Comments

@igorsantos07
Copy link

igorsantos07 commented Oct 22, 2024

Bug Report

Expected Behaviour

On iOS 17 (and previous versions), our app was working correctly, and receiving a single call to the push handler.

Actual Behaviour

Once I updated my device to iOS 18, it started calling the handler twice. This does not happen on background, and wasn't reproduced on other two devices with iOS 17, nor our logs show it's suddenly sending two pushes.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Not adding the rest given no one is probably going to fix it, but I wanted to report it anyway so users are a tiny bit aware of the problem, and possible workarounds.

My best bet so far is trying ideas with Lodash functions: lodash/lodash#2403

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

(Android) Device Vendor (e.g. Samsung, HTC, Sony...)

Androids are not affected

iOS

Version 18.0.1

cordova info Printout

Ignored as well

Sample Push Data Payload

Ignored as well

Sample Code that illustrates the problem

Ignored as well

Logs taken while reproducing problem

Ignored as well

@erisu
Copy link

erisu commented Oct 23, 2024

This issue occurs with iOS 18+ and is not related to the plugin.

I have already created a minimal reproduction repository of a native iOS application, demonstrating that this issue exists outside of Cordova and the plugin

I submitted a report to Apple prior to the release of iOS 18 but have not yet received a response.

@igorsantos07
Copy link
Author

Nice, thanks! Good to see you around <3

@erisu
Copy link

erisu commented Nov 13, 2024

@igorsantos07 I pushed a PR that could be the solution.

#303

I see two possible approaches to resolve this issue:

1. Native/Plugin (PR Solution)

In this PR, I've added logic specifically for iOS 18.0 to check if the notification payload is a duplicate.

The duplication check is based on two key pieces of information:

  1. The payload's date/timestamp
  2. The payload's content

If both the timestamp and content are identical, the second payload is discarded, preventing duplicate processing.

2. App Developer (Alternative Solution)

An alternative solution would require app developers to handle the duplicate detection on the front-end.

For example, developers could:

  • Compare the payload content themselves on the front-end.
  • Implement a debounce mechanism, as you suggested in the ticket description.

Currently, the payload's date/timestamp is not passed to the front-end, so developers would need to manage this comparison themselves.

Let me know your thoughts:

  • If the PR looks good, I can go ahead and merge it.
  • If the detection mechanism seems too strict and might prevent valid cases, we could close the PR and leave it up to app developers to implement their own checks.
    • Anther note is we could consider adding a preference flag in the future to allow users to disable this mechanism if it turns out to be restrictive for some, while others might find it helpful.

Just to reiterate, this fix only applies to iOS 18.0. I’ve tested it with the official release of iOS 18.1, and the issue seems resolved. However, I couldn’t find any comments in the Release Notes, and they haven't responded to my bug ticket yet.

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

No branches or pull requests

2 participants