Deeplinking

Available in Batch 1.15.0 and higher

URLs present in notifications and mobile landings/in-app messages are handled by the Batch SDK in the following ways:

  • the default implementation by the SDK will automatically create a new intent using Intent i = new Intent(ACTION_VIEW, deeplink) with any URL it encounters
  • alternatively you can use a BatchDeeplinkInterceptor to handle the URL your way

Add an interceptor

  • Kotlin
  • Java
//Inside app onCreate() before Batch.setConfig()
Batch.Actions.setDeeplinkInterceptor(object: BatchDeeplinkInterceptor {
    override fun getTaskStackBuilder(context: Context, deeplink: String): TaskStackBuilder? {
    	//Called only on puhs notifcations
    	//Allowing you to create a activities task stack when a push is clicked
        TODO("not implemented")
    }

    override fun getIntent(context: Context, deeplink: String): Intent? {
    	//Called for notifications and mobile landings/in-app messages
    	//Allowing you to customize the deeplink intent
        TODO("not implemented")
    }

    override fun getFallbackIntent(context: Context): Intent? {
    	//Called for notifications and mobile landings/in-app messages
    	//Allows you to create a fallback when a previous task stack builder or intent could not be launched.
        return super.getFallbackIntent(context)
    }
})

The method getFallbackIntent(context) doesn't need to be overrided, by default Batch will use the LAUNCHER activity from your manifest.