OneSignal / OneSignal-Android-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native Android or Amazon app with OneSignal. https://onesignal.com
Other
604 stars 368 forks source link

[Bug]: 829377 crash when receiving a push notifications with two buttons #1815

Closed felixmede closed 1 year ago

felixmede commented 1 year ago

What happened?

The app crashes upon receiving a push notification with two buttons with the error

java.lang.IllegalArgumentException: Unsupported value: 'com.onesignal.notifications.internal.Notification$ActionButton@9b88d51' of type 'class com.onesignal.notifications.internal.Notification$ActionButton'

Steps to reproduce?

1. setup a device to receive a push message
2. start up the flutter(android) app
2. send a test message with two buttons and actions

What did you expect to happen?

the message getting displayed in the notifications

OneSignal Android SDK version

5.0.0

Android version

10

Specific Android models

Samsung Galaxy S9

Relevant log output

/OneSignal(20974): [main] initWithContext(context: android.app.ReceiverRestrictedContext@bf8e31f, appId: null)
D/OneSignal(20974): [main] Retrieving service interface com.onesignal.notifications.internal.bundle.INotificationBundleProcessor
D/OneSignal(20974): [main] Already instantiated: com.onesignal.notifications.internal.bundle.impl.NotificationBundleProcessor@723fe2b
D/OneSignal(20974): [main] NotificationWorkManager enqueueing notification work with notificationId: ba543840-111c-4295-947c-49ef7baf1ff3 and jsonPayload: {"google.delivered_priority":"normal","google.sent_time":1692950902217,"google.ttl":259200,"google.original_priority":"normal","custom":"{\"i\":\"ba543840-111c-4295-947c-49ef7baf1ff3\",\"a\":{\"actionButtons\":[{\"icon_type\":\"custom\",\"id\":\"testAction\",\"text\":\"test\"},{\"icon_type\":\"custom\",\"id\":\"testAction2\",\"text\":\"testAction\"}],\"actionId\":\"__DEFAULT__\"}}","pri":"5","vis":"1","from":"982098383328","alert":"test message","title":"test title","google.message_id":"0:1692950902239422%d30ed4fdf9fd7ecd","google.c.sender.id":"982098383328"}
D/OneSignal(20974): [DefaultDispatcher-worker-1] Retrieving service interface com.onesignal.notifications.internal.generation.INotificationGenerationProcessor
D/OneSignal(20974): [DefaultDispatcher-worker-1] Already instantiated: com.onesignal.notifications.internal.generation.impl.NotificationGenerationProcessor@6d086e6
D/OneSignal(20974): [DefaultDispatcher-worker-1] NotificationWorker running doWork with data: Data {json_payload : {"google.delivered_priority":"normal","google.sent_time":1692950902217,"google.ttl":259200,"google.original_priority":"normal","custom":"{\"i\":\"ba543840-111c-4295-947c-49ef7baf1ff3\",\"a\":{\"actionButtons\":[{\"icon_type\":\"custom\",\"id\":\"testAction\",\"text\":\"test\"},{\"icon_type\":\"custom\",\"id\":\"testAction2\",\"text\":\"testAction\"}],\"actionId\":\"__DEFAULT__\"}}","pri":"5","vis":"1","from":"982098383328","alert":"test message","title":"test title","google.message_id":"0:1692950902239422%d30ed4fdf9fd7ecd","google.c.sender.id":"982098383328"}, android_notif_id : 0, is_restoring : false, os_notif_id : ba543840-111c-4295-947c-49ef7baf1ff3, timestamp : 1692950902, }
I/OneSignal(20974): [DefaultDispatcher-worker-6] Fire remoteNotificationReceived
I/OneSignal(20974): [DefaultDispatcher-worker-5] Fire notificationWillShowInForegroundHandler
D/OneSignal(20974): [DefaultDispatcher-worker-1] NotificationWillDisplayEvent.preventDefault()
D/AndroidRuntime(20974): Shutting down VM
E/AndroidRuntime(20974): FATAL EXCEPTION: main
E/AndroidRuntime(20974): Process: com.medel.ai.redi.dev, PID: 20974
E/AndroidRuntime(20974): java.lang.IllegalArgumentException: Unsupported value: 'com.onesignal.notifications.internal.Notification$ActionButton@9b88d51' of type 'class com.onesignal.notifications.internal.Notification$ActionButton'
E/AndroidRuntime(20974):    at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:297)
E/AndroidRuntime(20974):    at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:277)
E/AndroidRuntime(20974):    at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:285)
E/AndroidRuntime(20974):    at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:285)
E/AndroidRuntime(20974):    at io.flutter.plugin.common.StandardMethodCodec.encodeMethodCall(StandardMethodCodec.java:38)
E/AndroidRuntime(20974):    at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:119)
E/AndroidRuntime(20974):    at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:102)
E/AndroidRuntime(20974):    at com.onesignal.flutter.FlutterRegistrarResponder$4.run(FlutterRegistrarResponder.java:76)
E/AndroidRuntime(20974):    at android.os.Handler.handleCallback(Handler.java:883)
E/AndroidRuntime(20974):    at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime(20974):    at android.os.Looper.loop(Looper.java:237)
E/AndroidRuntime(20974):    at android.app.ActivityThread.main(ActivityThread.java:8167)
E/AndroidRuntime(20974):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(20974):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
E/AndroidRuntime(20974):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

Code of Conduct

jennantilla commented 1 year ago

@felixmede thanks for reaching out! I've been able to reproduce this on Flutter, so we'll get working on a solution right away!

Aksoyhlc commented 1 year ago

i have the same problem

jennantilla commented 1 year ago

@Aksoyhlc thanks for the report! Can you please confirm which SDK you are using--so far, I've only been able to reproduce this on Flutter, so if you are experiencing this with the native Android SDK or another wrapper, please let us know!

Aksoyhlc commented 1 year ago

@jennantilla Hello, I am also getting this error in Flutter. I tried onesignal_flutter 5.0.0 on Xiaomi and Emulator devices, the application was stopped on all of them and I received the reported error.

Our log records are the same, so I do not re-upload them.

emawby commented 1 year ago

Fixed in https://github.com/OneSignal/OneSignal-Flutter-SDK/pull/743

jennantilla commented 1 year ago

@felixmede thank you for your patience. We have a fix for this on the latest Flutter release, 5.0.2.

Please let us know if you have any additional questions or concerns.