0

I am using react-native-marketingcloudsdk library in my React native project, For android to set the default_notification_color I have tried both AndroidManifest.xml & firebase.json ways, but still when I receive push notification from SFMC It's showing only the Blue colour, If I receive push notification from fcm API the colour which I have applied is reflecting.

---AndroidManifest.xml
<meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/accentColor"
        tools:replace="android:resource" />

---firebase.json
{
  "react-native": {
    "android_task_executor_maximum_pool_size": 10,
    "android_task_executor_keep_alive_seconds": 3,
    "messaging_android_notification_color": "@color/accentColor"
  }
}

2 Answers 2

1

You can customize notifications. See the documentation: https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/notifications/customize-notifications.html

0

Thanks for @Bill Mote, I have set the notification color by adding below code in MainApplication.java MarketingCloudSdk.init()

.setNotificationCustomizationOptions(
                        NotificationCustomizationOptions.create(new NotificationManager.NotificationBuilder() {
                            @NonNull @Override
                            public NotificationCompat.Builder setupNotificationBuilder(@NonNull Context context, @NonNull NotificationMessage notificationMessage) {
                                NotificationCompat.Builder builder =
                                    NotificationManager.getDefaultNotificationBuilder(
                                        context,
                                        notificationMessage,
                                        NotificationManager.createDefaultNotificationChannel(context),
                                        R.drawable.ic_notification
                                    );
                                //Set Notification Icon Color
                                builder.setColor(getResources().getColor(R.color.accentColor));

                                builder.setContentIntent(
                                    NotificationManager.redirectIntentForAnalytics(
                                        context,
                                        PendingIntent.getActivity(
                                            context,
                                            new Random().nextInt(),
                                            context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()),
                                            PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE
                                        ),
                                        notificationMessage,
                                        true
                                    )
                                );
                                return builder;
                            }
                        })
                    )
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .