ContentIntentBuilder

fun interface ContentIntentBuilder

Implement this interface to build a custom intent to be executed when the notification is tapped

Note: Direct to URI notifications using the _u parameter will never call {@link #build(Context, Bundle)}



Example of usage directing users to SaleActivity when a notification has the custom field special_price defined.


public class SaleContentIntentBuilder implements ContentIntentBuilder {
    {@literal @}Nullable
    {@literal @}Override
    public PendingIntent build(context: Context, bundle: Bundle) {
        if(bundle.containsKey("special_price")) {
            val intent = Intent(context, SaleActivity.class);
            return PendingIntent.getActivity(context, 12345, intent, PendingIntent.FLAG_UPDATE_CURRENT|PendingIntent.FLAG_IMMUTABLE);
        }

        // return null to keep the default behavior
        return null
    }
}

Add your implementation using {@link NotificationConfig#setContentIntentBuilder(ContentIntentBuilder)}


    ...
    val marigold = Marigold()
    Marigold.startEngine(getApplicationContext(), "your sdk key")
    val notificationConfig = NotificationConfig()
    notificationConfig.setContentIntentBuilder(SaleContentIntentBuilder())
    marigold.setNotificationConfig(notificationConfig)
    ...

Functions

Link copied to clipboard
abstract fun build(context: Context, bundle: Bundle): PendingIntent?

This method is called to build the intent to be executed when the notification is tapped Please set your own ContentIntentBuilder using NotificationConfig.setContentIntentBuilder