0

We're seeing an issue with multiple notifications on Android 13. Previous Android versions are working fine.

Repo steps

  1. Send 2 push notifications to a device
  2. Tap on one of the notifications
  3. Kill the app
  4. Tap on the remaining notification

Result - Nothing happens, the notification is not dismissed, and no action happens

Environment

  • SFMC SDK 8.0.8 & 8.0.9
  • Device Samsung A51 & S10

Docs followed

https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/notifications/customize-notifications.html

This is a sample of how the PendingIntent is created:

        val flag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
        } else {
            PendingIntent.FLAG_UPDATE_CURRENT
        }

        return NotificationCustomizationOptions.create(
            R.drawable.<some icon>,
            { context, notificationMessage ->
                val url = notificationMessage.url

                // Needed for multiple notifications
                val requestCode = Random().nextInt()

                if (url.isNullOrEmpty()) {

                    PendingIntent.getActivity(
                        context,
                        requestCode,
                        Intent(context, SomeActivity.class).apply {
                            action = "SomeAction"
                        },
                        flag
                    )
                } else {

                    // Handle link
                    PendingIntent.getActivity(
                        context,
                        requestCode,
                        Intent(context, SomeOtherActivity.class).apply {
                            action = "SomeAction"
                            putExtra("url_key", url)
                        },
                        flag
                    )
                }
            },
            null,
        )

We have tried different flags for the intent associated with the pendingIntent but the behavior is always the same:

flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP

Note: We are not seeing this issue with notifications created using the Firebase messaging sdk. We even copied the associated pendingIntent method, but this still has the same issue:

            { context, notificationMessage ->
                // Needed for multiple notifications
                val requestCode = Random().nextInt()

                val url = notificationMessage.url

                val intent = Intent("SomeAction").apply {
                    setPackage(context.packageName)
                    flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
                    if (!url.isNullOrEmpty()) {
                        // Handle link
                        putExtra("url_key", url)
                    }
                }

                // Handle link
                PendingIntent.getActivity(
                    context,
                    requestCode,
                    intent,
                    flag
                )
            }
1
  • I repeated these steps exactly as described and everything works as expected, however, I do not have your Samsung devices. I can tell you that in all cases where customers have previously had this complaint they were handling their own notifications and either not using a unique notification identifier or calling cancelAll on the PendingIntent(s). And when I say, "in all cases", that's been twice in 8 years. :)
    – Bill Mote
    May 30, 2023 at 14:12

1 Answer 1

0

From Android S, the flag should be update to:

    val flag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
        PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
    } else {
        PendingIntent.FLAG_UPDATE_CURRENT
    }

You must log in to answer this question.

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