Wrong event triggered when push notification is opened on iOS
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
- Send a push notification to an iOS device from firebase
- 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
same here
I am also facing the exact issue. Any workaround?