OneSignal/OneSignal-Xamarin-SDK

App is in closed state tapping on notification not getting any data with 4.1.2

MATAUDI opened this issue · 11 comments

Description:

App is in closed state on Android tapping on notification NotificationOpened not getting fired, failed to captured additional data passed on to notification for deep linking.
OneSignal.Default.NotificationOpened += _notificationOpened;

Environment

Xamarin Forms 5.0.0.2125
Install OneSignalSDK.Xamarin 4.1.2 (all the projects)

Steps to Reproduce Issue:

Use Case 1: (It does not work correctly)

  1. Build app and swipe away, app is in closed state
  2. Send push notification from OneSignal Portal, with additional data
  3. OneSignal.Default.NotificationOpened += _notificationOpened; not getting called in closed state

Use Case 2: (Works correctly)

  1. Build app, app is in background/foreground
  2. Send push notification from OneSignal Portal, with additional data
  3. OneSignal.Default.NotificationOpened += _notificationOpened; getting called in app is in background/foreground

@jkasten2 any news on this? Do you have any idea what could be causing this to happen?

@tanaynigam @jkasten2 any news on this? Do you have any idea what could be causing this to happen?

@MATAUDI I have been unable to reproduce the issue. Is it possible for you to provide me with the details regarding the additional data passed in the notification for deep linking?

@tanaynigam I don't use deep link, I use "NotificationOpened" to capture the additional data that is sent from OneSignal (key, value)... when I want to take that additional data with the app closed (without being in the background) I can't capture it, it does not enter "NotificationOpened".

Here the same. We are currently migrating from Com to SDK. This is the last big problem that prevents the current delivery. However, this is only happening on iOS for us. On Android, everything seems to be running as before.
If the app was closed (by task), then on iOS the NotificationOpened is not called. On Android it is.

Environment

Xamarin Forms 5.0.0.2125
Install OneSignalSDK.Xamarin 4.3.0 (all the projects)

I'm commenting here as I have the same issue. I put up a question too, I see several like this and all seem to be going with no replies. It is also delaying a delivery for me, Android only.

Xamarin Forms 5.0.0.2515
OneSignalSDK.Xamarin 4.3.0

Found a solution (Android 13) that fixed it for me:
#315 (comment)

I was able to reproduce the issue that you have been experiencing @MATAUDI. I have tested @fatderda's solution and it works.
If your NotificationOpened handler is not firing on cold start put the NotificationOpened handler before the OneSignal initialization.

OneSignal.Default.NotificationOpened += HandleNotificationOpened;
OneSignal.Default.Initialize(<OneSignalAppId>);

I still don't get the event when the app was closed on iOS. When clicking the Notification the App opens, but after binding the event nothing happens. On Android it works as suspected.

I doesn't matter when the event was bound. I tried it as one of the first lines and after the initialization.

Is it mandatory to add a Notification Service Extension for iOS? I don't use it, because so far (before the upgrade) it worked without it. I can't deliver our product this way because important data is not updated when the notification is opened.

What must/can I do to finally get the meta data or the event?

FYI: I'm using Xamarin.Forms 5.0.0.2545 not a Single View App and OneSignalSDK.Xamarin 4.3.2

Nothing changed with 4.3.3.
I have now also tried to bind the NotificationOpened event before and once after the Initialize method. Both are not called after the cold start.