FirebasePushNotificationPlugin icon indicating copy to clipboard operation
FirebasePushNotificationPlugin copied to clipboard

Wrong event triggered when push notification is opened on iOS

Open shishigami777 opened this issue 5 years ago • 2 comments

I am trying to handle the event when a user taps on the push notification in his device. To do this, I am using the OnNotificationOpened event. In an Android device it works as expected. However, in an iOS device, in the same situation, this event is not triggered: the OnNotificationReceived is triggered instead.

Bug Information

Version Number of Plugin: 3.0.3 Device Tested On: iPhone 6s iOS 13.3 Simulator Tested On: iPhone 11 iOS 13.3 Version of VS: Visual Studio for Mac 2019 v8.4 Version of Xamarin: Xamarin.Forms v4.4.0.991477 Versions of other things you are using:

Steps to reproduce the Behavior

  1. Send a push notification to an iOS device from firebase
  2. Open the notification on the iOS device

Expected Behavior

In the code, I expect the "OnNotificationOpened" event to be triggered (this is the behaviour when I run the same code on Android).

Actual Behavior

The "OnNotificationReceived" event is triggered (this event should be triggered when the notification is received on the device, not when it is opened).

Code snippet

  CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
  {
    System.Diagnostics.Debug.WriteLine("Received");
    // On iOS this event is triggered when the notification is opened
    if (Device.RuntimePlatform == Device.iOS)
    {
      HandleOpenedNotification(p.Data);
    }
  };

  CrossFirebasePushNotification.Current.OnNotificationOpened += (s, p) =>
  {
    System.Diagnostics.Debug.WriteLine("Opened");
    HandleOpenedNotification(p.Data);
  };

Screenshots

shishigami777 avatar Jan 15 '20 08:01 shishigami777

same here

devKlausS avatar May 04 '20 11:05 devKlausS

I am also facing the exact issue. Any workaround?

sawankumarbundelkhandi avatar May 14 '20 21:05 sawankumarbundelkhandi