In-App Messaging in Android Apps that use SDK Version 10
The processes for implementing and customizing in-app messaging have been updated in version 10 of the SDK. To upgrade your app to version 10 of the SDK, first update the initialization code. Then, use these code examples to update the in-app messaging code in your app.
Implement IAM on Android
Use this code example to implement in-app messaging during SDK initialization.
1SFMCSdk.configure(applicationContext as Application, SFMCSdkModuleConfig.build{2 engagementModuleConfig = MarketingCloudConfig.builder().apply{3 // Other configuration options4 // Tell the SDK how to handle button clicks in an In-App Message5 setUrlHandler(UrlHandler{ context, url, _ ->6 PendingIntent.getActivity(7 context,8 Random().nextInt(),9 Intent(Intent.ACTION_VIEW, url.toUri()),10 PendingIntent.FLAG_UPDATE_CURRENT11)12})13}.build(applicationContext)14}){15 // TODO handle initialization status16}
Optional Methods
Use this code example to set the in-app message listener.
1MarketingCloudSdk.requestSdk{ engagementSdk ->23 engagementSdk.inAppMessageManager.setInAppMessageListener(object :4 InAppMessageManager.EventListener{56 override fun shouldShowMessage(message: InAppMessage): Boolean{78 return if(shouldShowMessage /* Your Custom logic confirming to show in-app message */){9 true10}else{11 // Store message id for later12 val blockedMessageId = message.id13 false14}15}1617 override fun didShowMessage(message: InAppMessage) = Unit18 override fun didCloseMessage(message: InAppMessage) = Unit19})20}
Prevent or Delay Message Display
Use this code example to prevent or delay the display of an in-app message.