thomasgalliker / Plugin.FirebasePushNotifications

Receive and handle firebase push notifications in .NET MAUI apps
MIT License
65 stars 5 forks source link

[Bug] Push notifications delivered twice when iOS 18 app runs in foreground mode #70

Closed thomasgalliker closed 1 month ago

thomasgalliker commented 1 month ago

Description

Push notifications sent to iOS 18.0 devices are delivered twice. It is yet unclear what the reason for this behavior is. There are signs that it the problem was introduced with iOS 18 - but it cannot be ruled out that we also have to adjust some code in this library. If we need to fix anything here, it would also have to be fixed in the Xamarin-based firebase push notification library (CrossGeeks/FirebasePushNotificationPlugin).

Steps to Reproduce

  1. Install sample app on a iOS 18 device and run it in foreground mode
  2. Request push notification permissions
  3. Register for push notifications
  4. Subscribe to push notification events
  5. Subscribe to topic 'general'
  6. Use FCM token in postman to send following message:
{
    "message": {
        "topic": "general",
        "notification": {
            "title": "Topic Title",
            "body": "Topic Body"
        }
    }
}

Expected Behavior

Actual Behavior

Basic Information

Screenshots, Attachments, Links

thomasgalliker commented 1 month ago

The workaround for duplicate iOS 18 push notifications is available in version 2.5.8-pre and later. You can enable/disable the workaround and configure the period of time between which a certain identifier is recognized as 'duplicate'.

 .UseFirebasePushNotifications(o =>
  {
#if IOS
            o.iOS.iOS18Workaround.Enabled = true;
            o.iOS.iOS18Workaround.WillPresentNotificationExpirationTime = TimeSpan.FromSeconds(3);
#endif
 })

This code will be removed as soon as iOS 18 delivers a fix.