OneSignal/OneSignal-Xamarin-SDK

App is in closed State tapping on notification not getting any data with 4.1.0 Android 4.0.0 works fine

Dipannita20 opened this issue · 8 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

  1. Xamarin forms 5.0.0.2125
  2. Migrated OneSignal 3.10.6 to 4.1.0
  3. Started seeing this error

Steps to Reproduce Issue:

  1. Add 4.1.0 to all the projects
  2. Build app and swipe away, app is in closed state
  3. Send push notification from OneSignal Portal, with additional data
  4. Observe addition data is missing
  5. Observe log in Android logcat -> OneSignal.Default.NotificationOpened += _notificationOpened; not getting called in closed state
  6. Observe OneSignal.Default.NotificationOpened += _notificationOpened; getting called in app is in background/foreground

Anything else:

(crash stacktraces, as well as any other information here)

Attached Android logcat during the test flow
onesignal_exception.txt

@tanaynigam @jkasten2 any update on this, do you need any more information on this?

I have the same problem, when the app is in closed state, "OneSignal.Default.NotificationOpened += _notificationOpened;" stops working, but if the app is in the foreground or background it works correctly.

Is there any way to fix this?

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

I am also having this issue. I would like to deep link from the closed state on android, but this problem is blocking me. Works on iOS

Same issue here (OneSignalSDK.Xamarin 4.1.3 & Android Target 13.0). Any news on this?

Same issue here but with OneSignalSDK.Xamarin 4.3.0 and iOS. On Android everything works great.

Finally found a solution for this problem (Android 13).
I had to put the NotificationOpened handler before the OneSignal initialization. The handler probably worked when the app was in background because then the handler was set (as opposed to a cold start).

OneSignal.Default.NotificationOpened += HandleNotificationOpened;
OneSignal.Default.Initialize(YourOneSignalKey);

I was able to reproduce the issue that you have been experiencing @Dipannita20. 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>);