UrlHandler

Package: com.salesforce.marketingcloud

Type: fun interface

SDK Version: 11.0.0

Target: androidJvm

Module: Common v1.0.0

Description 

This interface handles URL events from push notifications or in-app messages that require processing. It allows you to define custom behavior when users interact with URLs in Marketing Cloud messages.

Declaration 

1fun interface UrlHandler

Methods 

handleUrl 

1abstract fun handleUrl(
2    context: Context,
3    url: String,
4    urlSource: String
5): PendingIntent?

Returns the PendingIntent to execute when a push notification action containing a URL needs display.

Parameters:

  • context (Context) - Android context
  • url (String) - The URL to handle
  • urlSource (String) - Source of the URL event

Returns:

PendingIntent? - Nullable PendingIntent for the notification action. Return null if you want the SDK to handle the URL using default behavior.

Nested Types 

Companion 

1object Companion

A companion object for the UrlHandler interface.

Usage 

As a functional interface (fun interface), UrlHandler can be implemented using a lambda expression:

1val urlHandler = UrlHandler { context, url, urlSource ->
2    // Custom URL handling logic
3    // Return a PendingIntent or null
4    null
5}