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 message from SMC doesn't appear even though FCM from Firebase can be shown. #9

Closed trysandayou closed 1 year ago

trysandayou commented 1 year ago

Thank you for your great work.

as is

Push messages from SMC doesn't be shown in Android. Even though push messages from Firebase console is shown as head-up notification. (For iOS, this plugin works fine. Show the push message in head-up notification.)

to be

Push messages from SMC is shown as head-up notification like from firebase console.

logs in console

When got the message from SMC, the following line is shown : D/FLTFireMsgReceiver( 8926): broadcast received for message.

reproduce procedure

  1. Init SMC SDK and setContactKey works fine. SMC show the user with Firebase Token.

  2. Open firebase console by Web browser.

  3. Send test message to flutter application.

  4. Check the head-up notification.

  5. Both foreground / background, message is shown in head-up.

  6. Console log is shown as follows: D/FLTFireMsgReceiver( 8926): broadcast received for message W/FirebaseMessaging( 8926): Missing Default Notification Channel metadata in AndroidManifest. Default value will be used.

  7. Next, open SMC Mobile push page and create message

  8. Send message to flutter application

  9. Nothing happens D/FLTFireMsgReceiver( 8926): broadcast received for messag

Would you please let me know any possible solutions?

trysandayou commented 1 year ago

Now I know that the issue is complex. What I did in my flutter code is...

  1. follows the instruction
  2. In my flutter code, use FlutterLocalNotificationsPlugin to show the head message.
  3. SF's push is not "notification" but "data". So I get the data from "data" and I can see the head message.

The main issue is that Salesforce SDK doesn't show the head message by itself.
And also, this is important, Salesforce doesn't track open the push message or not. Needless to say, the setAnalyticsEnabled(true) is set (SDK's default)

What is the main issue for this?

trysandayou commented 1 year ago

Now I understand the situation.
I needed to implement handler for Android. And now my app can show push message from SMC.

Just a log for future user like me:

Thank you for this plugin!

rodrigobastosv commented 1 year ago

I am having trouble integrating this plugin with FCM. Maybe i'm missing something but don't i need do set the fcm token somehow on the salesforce? I found no method to do that.

alexdriba commented 1 year ago

Hi @trysandayou. Did you solve the issue of displaying the Android notification when app is in background. As you mentioned MC notifications are just data messages, so Android does not display them onto the notification tray. I'm struggling with that, any clue?

rodrigobastosv commented 1 year ago

One possible solution is to receive the notification and display a local notification @alexdriba .

alexdriba commented 1 year ago

Thanks @rodrigobastosv but not that exactly. I'm looking for solving the issue of SFMC not sending a notification payload on their Notifications. By not doing that, background notifications on Android are not working as expected.

trysandayou commented 1 year ago

hi @alexdriba and @rodrigobastosv Yes, I added local notification in my flutter app and Background message is shown correctly.

Just fyi, I used FlutterLocalNotificationsPlugin to implement local notification.