Configure Button and Carousel Actions for Android Push Notifications

Marketers can configure the action when an end user taps a button or a carousel image in a push notification. The actions for Web URL and App URL require that you implement UrlHandler as a new SDK initialization method.

This example shows how to configure the SDK to handle button and carousel clicks in push messages.

1SFMCSdk.configure(applicationContext as Application, SFMCSdkModuleConfig.build {
2  pushModuleConfig = MarketingCloudConfig.builder().apply {
3    setApplicationId("{mc_application_id}")
4    setAccessToken("{mc_access_token}")
5    setSenderId("{fcm_sender_id}")
6    setMarketingCloudServerUrl("{marketing_cloud_url}")
7    setMid("{mid}")
8    setNotificationCustomizationOptions("{your instance of NotificationCustomizationOptions}")
9
10    // Tell the SDK how to handle button & Carousel clicks in a Push Notification
11    setUrlHandler(UrlHandler { context, url, _ ->
12      PendingIntent.getActivity(
13        context,
14        Random().nextInt(),
15        Intent(Intent.ACTION_VIEW, Uri.parse(url)),
16        PendingIntent.FLAG_UPDATE_CURRENT
17      )
18    })
19    // Other configuration options
20  }.build(applicationContext)
21}) {
22  // TODO handle initialization status
23}