Custom Notifications Guide

Send custom in-app notifications in the StreamLayer Android SDK. Use SLRCustomNotification to create and display custom notification layouts with configurable icons, titles, and navigation destinations.

Custom Notifications Guide

You can send custom in-app notifications through the StreamLayer Element. Extend the SLRCustomNotification class to define your notification. The class properties are:

  • title — notification title
  • description — notification description
  • layoutId — custom layout resource (defaults to R.layout.slr_item_notification if not provided)
  • actionId — navigation destination ID
  • iconBackgroundColor — background color for the icon
  • iconUrl — custom icon URL

Override bindView(view: View) to interact with the view or set the view data manually:

class DemoNotification(
              override val title: String? = null,
              override val description: String? = null,
              override val layoutId: Int? = R.layout.layout_notification,
              override val actionId: Int? = R.id.action_custom_3,
              override val iconBackgroundColor: Int? = null,
              override val iconUrl: String? = null,
              val viewIteractor: ((View) -> Unit)? = null
        ) : SLRCustomNotification(title, description, layoutId, actionId, iconBackgroundColor, iconUrl) {
            override fun bindView(view: View) { viewIteractor?.invoke(view) }}

Send the notification through StreamLayer.sendCustomNotification():

StreamLayer.sendCustomNotification(notification:SLRCustomNotification)

Related