Steps:
- Setup an Android project with targetSdkVersion 31
- In the same project, include version v8.0.0 of MarketingCloud: implementation "com.salesforce.marketingcloud:marketingcloudsdk:8.0.0"
- Setup MarketingCloud SDK using following instructions
- "Full Control Customization" https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/notifications/customize-notifications.html
- Compile the app in Android Studio and run the app on Android 12 Beta
- Send a test notification and tap it
Result:
- Activity does not start.
- Following log is printed in Logcat
10-06 10:18:22.977 1534 3091 E NotificationService: Indirect notification activity start (trampoline) from com.example.app blocked
By rewriting following code
builder.setContentIntent(
NotificationManager.redirectIntentForAnalytics(
context,
PendingIntent.getActivity(
context,
Random().nextInt(),
Intent(context, MainActivity::class.java),
PendingIntent.FLAG_UPDATE_CURRENT
),
notificationMessage,
true
)
)
with
builder.setContentIntent(
PendingIntent.getActivity(
context,
Random().nextInt(),
Intent(context, MainActivity::class.java),
PendingIntent.FLAG_UPDATE_CURRENT
)
)
the app is launches correctly.
I think this problem is related to https://developer.android.com/about/versions/12/behavior-changes-12?hl=en#notification-trampolines
How to fix this problem?
redirectForAnalytics()
wrapper of thePendingIntent
, but this will affect the open analytics reported for the messages. We're looking into a solution.Android 30
which would work as-is today while we prepare a fix.