Documentation Index

Fetch the complete documentation index at: https://usercentrics.document360.io/llms.txt

Use this file to discover all available pages before exploring further.

Custom hyperlinks

Prev Next

By default, when a user taps on any hyperlink available in the UsercentricsUI banner, the given URL will be opened in a browser.

If you wish to customize this behavior, and capture these hyperlinks, you may leverage the already existing deep link mechanism from iOS and Android, to capture hyperlinks.

Define deep links

Define a deep link scheme for the links you will be catching, and provide the URL/s in the Usercentrics Admin Interface - Content page - First layer and Links sections.

Capture deep links

Configure Info.plist to listen a specific URL scheme

To capture deep links being clicked on your app, the first step is to configure Info.plist.

Deep link configuration on Info.plist

Catch deep links and provide custom implementation

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 deep links 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>

Catch deep links and provide custom implementation

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()
        }
    }
}