0

I have implemented the React Native SDK and I am successfully receiving push notifications on both platforms.

The problem I am having is that, on Android only, the notification builder seems to be ignoring all customisation I am passing. It shows only the default icon and notification title. I need the notification to show the content as well, including images - and it would be nice to show the correct icon too. It even seems to ignore custom notification channel IDs that I pass into it, and always defaults to a standard 'channel_01'.

I've tried basically everything at this stage but to no avail. My (current) init code, with the builder, looks like this:

MarketingCloudSdk.init(this,
      MarketingCloudConfig.builder()
        .setApplicationId(getString(R.string.salesforce_application_id))
        .setAccessToken(getString(R.string.salesforce_token))
        .setSenderId(getString(R.string.salesforce_sender_id))
        .setMarketingCloudServerUrl(getString(R.string.salesforce_mc_app_endpoint))
        .setNotificationCustomizationOptions(
          NotificationCustomizationOptions.create((context, notificationMessage) -> {
            NotificationCompat.Builder builder = NotificationManager.getDefaultNotificationBuilder(
              context,
              notificationMessage,
              NotificationManager.createDefaultNotificationChannel(context),
              R.mipmap.ic_small_icon
            );

            builder.setContentText(notificationMessage.alert());

            String customUrl = notificationMessage.url();
            Intent intent = new Intent(context, MainActivity.class);
            intent.setData(Uri.parse(customUrl));

            builder.setContentIntent(
              NotificationManager.redirectIntentForAnalytics(
                context,
                PendingIntent.getActivity(
                  context,
                  100,
                  intent,
                  PendingIntent.FLAG_IMMUTABLE
                ),
                notificationMessage,
                true
              )
            );

            return builder;
          })
        )
        .build(this),
      initializationStatus -> Log.e("INIT", initializationStatus.toString()));

I have also tried passing just the icon in the most basic setup as shown in the SDK docs (without providing a builder or any customisation) but the outcome is always the same - the notification displays only a title and the app icon, rather than the one I am providing.

As we are using another push library in the app, we also must include the Firebase messaging SDK, so I have extended this like so:

class MessagingService : FirebaseMessagingService() {

  override fun onNewToken(token: String) {
    super.onNewToken(token)

    // Marketing cloud SDK
    MarketingCloudSdk.requestSdk { it.pushMessageManager.setPushToken(token) }
  }

  override fun onMessageReceived(message: RemoteMessage) {
    if (PushMessageManager.isMarketingCloudPush(message)) {
      MarketingCloudSdk.requestSdk { it.pushMessageManager.handleMessage(message) }
    } else {
      //Not from Marketing Cloud. Must handle yourself.
      super.onMessageReceived(message)
    }
  }
}

Note that all other pushes, from FCM or other providers, are working as expected. This issue is only happening with pushes delivered from SFMC.

If anyone can tell me where I might be going wrong I'd really appreciate it as I've been banging my head against this wall for almost a week now and haven't made any progress!

Edit: As mentioned in a response below - I cannot remove the senderId as this breaks the implementation. Doing so results in no session token being associated with my user.

Thanks, Dan

1
  • I have figured this out. The Multiple providers documentation is wrong, or at least it is missing a step. In order for SFMC to receive firebase pushes, the push service which overrides firebasemessaging must be registered in the AndroidManifest file. I could only get this working with a .java file as trying to use kotlin gave me an error that the file was not found. Jul 12 at 14:00

1 Answer 1

0

I understand that you are using multiple push providers in your application. I would like to request you to check the documentation for Multiple Push Providers Implementation.

In the first code snippet, you are passing the senderId for Marketing Cloud initialization. For an MPP implementation, you should not be sending it. This could lead to inconsistent behavior in the SDK.

If you are still having trouble, please create a support case.

1
  • I have tried removing senderId from the initialisation, the result is that my user does not have a session token in mobilepush (which of course means it will not work). I think if senderId were the issue, I would not be receiving pushes at all - the actual connection with FCM/mobilepush seems to be working fine, it is the notification itself that is not displaying correctly and this is almost certainly an issue with the SDK. I have opened a support case and was directed to post here as they 'cannot help with implementation' May 22 at 8:36

You must log in to answer this question.

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