0

I am using multiple push sdks in my project. I have SF Auth SDK as well. I have configured SFMC properly and I can receive the notifications as well as the inbox messages, but when I interact with the push notification from notification tray I don't see the app opening rather a transparent background window opens and all I can see if the title "Notification Message"

my code

SFMCSdk.configure( applicationContext as Application, SFMCSdkModuleConfig.build { pushModuleConfig = MarketingCloudConfig.builder().apply { setApplicationId(BuildConfig.SALESFORCE_MC_APP_ID) setAccessToken("########") setMarketingCloudServerUrl(BuildConfig.SALESFORCE_MC_SERVER_URL) setMid(BuildConfig.SALESFORCE_MC_MID) setNotificationCustomizationOptions( NotificationCustomizationOptions.create(R.drawable.ic_stat_app_logo_transparent) ) setMarkMessageReadOnInboxNotificationOpen(true) setDelayRegistrationUntilContactKeyIsSet(true) setInboxEnabled(true) // Enable Inbox messaging }.build(applicationContext) } ) { initStatus -> when (initStatus.status) { com.salesforce.marketingcloud.sfmcsdk.InitializationStatus.SUCCESS -> { logVerbose("SFMC STATUS", "Marketing Cloud init was successful") SFMCSdk.requestSdk { sdk -> sdk.mp { try { FirebaseMessaging.getInstance().token.addOnCompleteListener { task -> if (task.isSuccessful) { SFMCSdk.requestSdk { sdk -> sdk.mp { logDebug( "FIREBASE_MESSAGING", "SUCCESS: task result: ${task.result}" ) it.pushMessageManager.setPushToken(task.result) } } } } } catch (e: ExceptionInInitializerError) { logError( "FIREBASE_MESSAGING", "FAILURE: Exception in initializer. ${e.message}" ) } } } } com.salesforce.marketingcloud.sfmcsdk.InitializationStatus.FAILURE -> { logError("SFMC STATUS", "Marketing Cloud failed to initialize.") } } 

I have tried other options as well, for example handling the channel, composition and pendingIntent through app as well but same behaviour

 fun createNotificationChannel(context: Context) { val channelId = "default_channel_id" val channelName = "Default Channel" val channelDescription = "This is the default notification channel" val importance = android.app.NotificationManager.IMPORTANCE_DEFAULT val channel = NotificationChannel(channelId, channelName, importance).apply { description = channelDescription } val notificationManager: android.app.NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as android.app.NotificationManager notificationManager.createNotificationChannel(channel) } ... SFMCSdk.configure( applicationContext as Application, SFMCSdkModuleConfig.build { pushModuleConfig = MarketingCloudConfig.builder().apply { setApplicationId(BuildConfig.SALESFORCE_MC_APP_ID) setAccessToken(it) setMarketingCloudServerUrl(BuildConfig.SALESFORCE_MC_SERVER_URL) setMid(BuildConfig.SALESFORCE_MC_MID) setMarkMessageReadOnInboxNotificationOpen(true) setDelayRegistrationUntilContactKeyIsSet(true) setInboxEnabled(true) // Enable Inbox messaging setUrlHandler(this@ABCApplication) setNotificationCustomizationOptions( NotificationCustomizationOptions.create { context, notificationMessage -> // Ensure the notification channel is created createNotificationChannel(context) val builder = NotificationCompat.Builder(context, "default_channel_id") builder.setContentTitle(notificationMessage.title) builder.setSmallIcon(R.drawable.ic_stat_app_logo_transparent) builder.setContentText(notificationMessage.alert) builder.setPriority(NotificationCompat.PRIORITY_DEFAULT) builder.setAutoCancel(true) builder.setContentIntent( NotificationManager.redirectIntentForAnalytics( context, PendingIntent.getActivity( context, Random().nextInt(), Intent(context, MainActivity::class.java), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ), notificationMessage, true ) ) val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as android.app.NotificationManager notificationManager.notify(Random().nextInt(), builder.build()) Log.d( "Notification", "Notification built and displayed successfully." ) builder } ) }.build(applicationContext) } ) { initStatus -> when (initStatus.status) { com.salesforce.marketingcloud.sfmcsdk.InitializationStatus.SUCCESS -> { logVerbose("SFMC STATUS", "Marketing Cloud init was successful") SFMCSdk.requestSdk { sdk -> sdk.mp { try { FirebaseMessaging.getInstance().token.addOnCompleteListener { task -> if (task.isSuccessful) { SFMCSdk.requestSdk { sdk -> sdk.mp { logDebug( "FIREBASE_MESSAGING", "SUCCESS: task result: ${task.result}" ) it.pushMessageManager.setPushToken(task.result) } } } } } catch (e: ExceptionInInitializerError) { logError( "FIREBASE_MESSAGING", "FAILURE: Exception in initializer. ${e.message}" ) } } } } com.salesforce.marketingcloud.sfmcsdk.InitializationStatus.FAILURE -> { logError("SFMC STATUS", "Marketing Cloud failed to initialize.") } } } 

and

 override fun handleUrl(context: Context, p1: String, p2: String): PendingIntent? { val intent = Intent(context, MainActivity::class.java).apply { action = Intent.ACTION_VIEW data = Uri.parse(p1) flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK } return PendingIntent.getActivity( context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ) } 

Any help would be greatly appreciated. Thanks.

4
  • Open a support case. Commented Jun 13, 2024 at 18:59
  • So, open a support case, BUT you're calling notify in your own code AND handing the builder back to the SDK. You have an implementation problem in this code. Commented Jun 13, 2024 at 19:06
  • @BilMote yes that I fixed. Now I am getting the notifications as I wanted, will open a case soon. Thanks. Commented Jun 14, 2024 at 1:01
  • No need for a case if you resolved it :) Commented Jun 14, 2024 at 15:18

1 Answer 1

0

Looks like you're calling notify from your own code. If you want to do that then you should return null to the SDK. Otherwise, remove the call to notify and let the SDK do it's work with the intent you provided.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.