cph-cachet / flutter-plugins

A collection of Flutter plugins developed by CACHET
550 stars 675 forks source link

notifications 3.0.0 (NPE) #1018

Open mening12001 opened 3 months ago

mening12001 commented 3 months ago

Remember to specify the plugin name in the title!

Device / Emulator and OS

Please complete the following information for each phone and/or emulator you're experiencing this bug on:

Describe the bug

An NullPointerException is encounter in NotificationListener: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference E/AndroidRuntime( 6843): at dk.cachet.notifications.NotificationListener.onNotificationPosted(NotificationListener.java:41)

To Reproduce

Receive an email on Gmail

Expected behavior

No error

Actual behavior

The app breaks with NPE

Screenshots

Screenshot 2024-08-11 at 18 31 54

Additional information

Attempting to track notifications from a foreground service

mening12001 commented 3 months ago

Solution:

intent.putExtra(NOTIFICATION_TITLE, Objects.nonNull(title)?title.toString():""); intent.putExtra(NOTIFICATION_MESSAGE, Objects.nonNull(text)?text.toString():"");