sefidgaran / salesforce-marketing-cloud

Salesforce Marketing Cloud MobilePush Flutter SDK
https://pub.dev/packages/sfmc_plugin
MIT License
6 stars 21 forks source link

Android push notification issue #10

Closed Cee-Ng closed 1 year ago

Cee-Ng commented 1 year ago

I'm working on a flutter project and using salesforce for in app messaging and push notifications.

I've done the set up by following the directions from the package and added the native set up and iOS seems fully functional and android can receive the in app notifications, but does not seem to be able to display the push notifications. But it does appear that the application is receiving them just hitting an error when trying to actually react to receiving them. I get this error below shortly after sending a push notification test. It points to code in the package, so I'm not sure if there are additional steps I was supposed to do on my side to go along with these changes or if this is an issue with the package itself. I have tried adding a notification icon image to override the empty one in the package, but there is now change observed. I suspect the issue lies mostly with the null pointer exception uriString but am having some issues figuring out how to address it or if that's an accurate assumption.

The particular run below was on a pixel 3 on android 10, though I have also checked on android 12 and 13 devices as well.

D/~!BehaviorManager(15538): Behavior found: BEHAVIOR_SDK_PUSH_RECEIVED E/~!NotificationManager(15538): Custom notification builder threw an exception. Using default notification builder. - Sdk Version: 8.0.8 E/~!NotificationManager(15538): java.lang.NullPointerException: uriString E/~!NotificationManager(15538): at android.net.Uri$StringUri.<init>(Uri.java:496) E/~!NotificationManager(15538): at android.net.Uri$StringUri.<init>(Uri.java:486) E/~!NotificationManager(15538): at android.net.Uri.parse(Uri.java:458) E/~!NotificationManager(15538): at com.example.sfmc_plugin.MainApplication._get_configBuilder_$lambda-1$lambda-0(MainApplication.kt:36) E/~!NotificationManager(15538): at com.example.sfmc_plugin.MainApplication.$r8$lambda$rz6V6LHdeoBXBTqlGelUiA0BIgE(Unknown Source:0) E/~!NotificationManager(15538): at com.example.sfmc_plugin.MainApplication$$ExternalSyntheticLambda0.setupNotificationBuilder(Unknown Source:0) E/~!NotificationManager(15538): at com.salesforce.marketingcloud.notifications.b.setupNotificationBuilder(Unknown Source:4) E/~!NotificationManager(15538): at com.salesforce.marketingcloud.notifications.a$a.run(Unknown Source:8) E/~!NotificationManager(15538): Unable to show notification due to an exception thrown by Android. - Sdk Version: 8.0.8 E/~!NotificationManager(15538): java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=com.salesforce.marketingcloud.DEFAULT_CHANNEL pri=0 contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x0 color=0x00000000 vis=PRIVATE) E/~!NotificationManager(15538): at android.app.NotificationManager.fixNotification(NotificationManager.java:516) E/~!NotificationManager(15538): at android.app.NotificationManager.notifyAsUser(NotificationManager.java:495) E/~!NotificationManager(15538): at android.app.NotificationManager.notify(NotificationManager.java:444) E/~!NotificationManager(15538): at com.salesforce.marketingcloud.notifications.a$a.run(Unknown Source:38)

Cee-Ng commented 1 year ago

After further digging we were able to determine this issue was because the push test did not have an app url, (was set to just open the app) which iOS handled without a problem, but android seemed to have an issue with as the library attempted to parse the null string. addressing that in the test appeared to fix the problem for now, but this may be a case that should be considered in an update to the package, since it includes the notification builder.