Skip to content

Capturing Hyperlinks

By default, when a user taps on any hyperlink available in the CMP, the UsercentricsUI opens the given URL in a browser.

Legal Links

If you wish to customize this behaviour, and capture these hyperlinks, you may leverage the already existing deeplink mechanism from iOS and Android, to capture CMP hyperlinks.

Define a deeplink scheme for the links you will be catching, and provide the URL/s in our Admin Interface.

Banner

Legal

Configure Info.plist to listen a specific URL scheme

In order to capture Deep Links being clicked on your app, the first step is to configure Info.plist.

Deep link configuration on Info.plist

Add a listener to AppDelegate.swift, and add the necessary logic for your custom implementation.

// On AppDelegate
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    return handleUrl(url)
}

func handleUrl(_ url: URL) -> Bool {
    if (url.scheme == "example" && url.host == "privacyPolicy") {
        // Custom Implementation for Link
        return true
    }
    return false
}

Configure AndroidManifest.xml to listen a specific URL scheme

In order to capture deeplinks being triggered in your app, we should create an Activity on AndroidManifest.xml that will be responsible for receiving callbacks.

<activity android:name=".DeepLinkActivity">

    <intent-filter android:label="deep link example">
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <data
            android:host="privacyPolicy"
            android:scheme="example" />
    </intent-filter>
</activity>

On create, add the necessary logic for your custom implementation.

class DeepLinkActivity: AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val data = intent?.data ?: return
        if (data.scheme == "example" && data.host == "privacyPolicy") {
            // Custom Implementation for Link
            finish()
        }
    }
}