Deep Link Handler

You will find a description about DeepLinkHandler class and methods details.

Introduction

DeepLinkHandler is a interface that defines how to configure navigation between a Server-Driven screen and a native screen.

Example

Creating a DeepLinkHandler

You have to create a class that implements the DeepLinkHandler interface and annotates it with @BeagleComponent, as listed below:

@BeagleComponent
class AppDeepLinkHandler : DeepLinkHandler {
    override fun getDeepLinkIntent(
        rootView: RootView,
        path: String,
        data: Map<String, String>?,
        shouldResetApplication: Boolean
    ) = Intent(path)
}

In the getDeepLinkIntent method, you can configure the navigation screens of the server-driven ui flows to their native screens, making sure that Beagle recognizes your rule.

AttributeTypeDefinition
rootViewRootViewRootView holds the reference to the activity or fragment
pathStringRoute parameter that can be set by Navigate.OpenNativeRoute(route: “navigate.myview”)
dataMap<String, String>?Parameter map that can be defined by OpenNativeRoute(route = “navigate.myview” , data = mapOf(“param1” to “paramValue”))
shouldResetApplicationBooleanOpens a screen with the route informed from a new flow and clears the stack of screens for the entire application.

Once you made it, it’s necessary modify the Android manifest file:

  1. Step 1: You must add an intent filter at the activity you wish to navigate to.
  2. Step 2: You will add an action tag that will identify this activity. The id name you used here is "navigate.myview"
  3. Step 3: Add an category tag and name it "android.intent.category.DEFAULT" , like the example below:
//AndroidManifest
<activity android:name=".activities.DeepLinkActivity">
    <intent-filter>
        <action android:name="navigate.myview"/>
        <category android:name="android.intent.category.DEFAULT"/>

    </intent-filter>
</activity>

And that’s it. Now you just need to call the Navigate action with the method OpenNativeRoute like the example below:

//Widget used to navigate to a native screen
Button(
    text = "Click to navigate!",
    onPress = listOf(
        Navigate.OpenNativeRoute("navigate.myview")
    )
)

Last modified February 11, 2021: create content (#298) (43225e15)