OneSignal / OneSignal-Xamarin-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Xamarin app with OneSignal. https://onesignal.com
Other
105 stars 50 forks source link

[question]: "App crashes when opening grouped notifications with different content in Xamarin Forms using OneSignal SDK" #378

Closed sarapura12 closed 1 month ago

sarapura12 commented 1 year ago

I am experiencing an issue with the grouping of notifications. We are sending notifications to devices using the OneSignal API, which includes headings, contents, android group, and android group message. The notifications that are grouped have different contents. When we try to open the grouped notification in the Android app, it throws a


NullReferenceException with the message "Object reference not set to an instance of an object." 
NativeConversion.NotificationToXam (Com.OneSignal.Android.OSNotification notification)
NativeConversion.NotificationOpenedResultToXam (Com.OneSignal.Android.OSNotificationOpenedResult result) OneSignalImplementation+OSNotificationOpenedHandler.NotificationOpened (Com.OneSignal.Android.OSNotificationOpenedResult notificationOpenedResult)
OneSignal+IOSNotificationOpenedHandlerInvoker.n_NotificationOpened_Lcom_onesignal_OSNotificationOpenedResult_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_p0)
JNINativeWrapper.Wrap_JniMarshal_PPL_V (_JniMarshal_PPL_V callback, System.IntPtr jnienv, System.IntPtr klazz, System.IntPtr p0)

This only happens when notifications with different contents are grouped. We want to be able to open the grouped notification without the app crashing and perform some actions based on the additional data sent with the notification. We have only implemented the SharedPush from the example in the repository.

How can we help?

emawby commented 1 year ago

@sarapura12 Thank you for reporting we will investigate. Which version of the OneSignal Xamarin SDK are you using?

sarapura12 commented 1 year ago

@sarapura12 Thank you for reporting we will investigate. Which version of the OneSignal Xamarin SDK are you using?

Thank you for looking into the issue. I am currently using v4.3.0.

sarapura12 commented 1 year ago

@emawby l have resolved the issue by updating to version 4.3.4. Additionally, I found that the 'android_group_message' field was being sent as a string, but now I am sending it as an object. {"en": "You have $[notif_count] new messages"} However, even after grouping the messages, the Android group message that I send does not appear. The messages are simply grouped with their title and heading.

emawby commented 1 year ago

Got it thank you for the update. We will investigate issues around grouping

shepherd-l commented 1 year ago

Is the issue that the grouped messages are not appearing as "You have $[notif_count] new messages”?

What are the Android versions of the devices you are seeing this issue on?

The property android_group_message only applies to devices on Android 6 and older. We also talk more about it here: https://documentation.onesignal.com/docs/notification-grouping#android-notification-grouping

If that isn't the case, could you also provide the message body you sent through the API and the response