Deep Links
UpdatedOur SDK supports redirects for notification links registered in Android by default. You can customize this behavior using CustomerIOPushNotificationCallback
.
To register a deep link, you must first add intent filters in your
AndroidManifest.xml
file.<intent-filter android:label="deep_linking_filter"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <!-- Accepts URIs that begin with "remote-habits://settings” --> <data android:host="settings" android:scheme="remote-habits" /> </intent-filter>
CustomerIOPushNotificationCallback
—a URL handler feature provided by the SDK. When configuring yourCustomerIO
instance, you can set the callback to handle notification behavior.Note that the if statement (
payload.deeplink.doesNotMatch()
) in the example below is just an example of what you might do if you handle some links with our SDK and handle others yourself.class MainApplication : Application(), CustomerIOPushNotificationCallback { override fun onCreate() { super.onCreate() val builder = CustomerIOBuilder( appContext = this cdpApiKey = "your-cdp-api-key", ) builder.addCustomerIOModule( ModuleMessagingPushFCM( moduleConfig = MessagingPushModuleConfig.Builder().apply { setNotificationCallback(this) }.build() ) ) builder.build() } override fun onNotificationClicked(payload: CustomerIOParsedPushPayload, context: Context): Unit? { // This if statement is an example of what you might do to handle // some links with our SDK and others yourself. if (payload.deepLink.doesNotMatch()) { // Return null so CustomerIO SDK can handle Notification Clicked return null } // Custom handling of Notification Clicked } }
When someone taps a push notification with a deep link, the SDK calls the CustomerIOPushNotificationCallback
specified in CustomerIOBuilder
object before it looks for default supported links.
The onNotificationClicked
function lets you override the SDK’s default click handler. If you return null
, the SDK will handle the click normally, opening the link in your app or web browser. Otherwise, you can handle the click yourself using the payload
and context
parameters.
Don’t forget to capture metrics
When you provide CustomerIOPushNotificationCallback
, don’t forget to capture notification metrics, otherwise our dashboards won’t record conversions properly!