Deep Links
Deep links enable your application to open specific screens or content directly from notifications, web pages, or external sources. By integrating deep links, you can guide users to precise destinations within your app — enhancing engagement and creating seamless navigation between notifications, campaigns, and in-app experiences.
Overview
Handling deep links in your Android application allows you to:
- Support Deep Link notification types from Actito.
- Handle custom URL schemes or HTTPS links from web pages.
Once configured, your app can interpret incoming URLs and display the appropriate screen or content dynamically.
Declaring a custom URL scheme
To enable your app to handle a custom URL scheme, declare an activity and its corresponding intent filter in your AndroidManifest.xml. Be sure to update the android:scheme attribute to match your own application’s scheme.
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.example" />
</intent-filter>
</activity>
With this configuration, links such as com.example://example.com/product?id=1 will automatically open your application.
Handling deep links intents
When a user opens a deep link — either from a notification or a web page — your declared activity receives an intent containing the URL. You can then parse and handle this intent within your activity as shown below:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Prevent processing the intent again on configuration changes
if (intent != null && savedInstanceState == null) {
handleIntent(intent)
}
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleIntent(it)
}
private fun handleIntent(intent: Intent) {
if (Actito.handleDynamicLinkIntent(this, intent)) {
// Dynamic link handled successfully
return
}
val uri = intent.data
if (uri != null) {
// Open a specific view or perform navigation based on the received URI
}
}
}
Supporting external deep links (Android 11+)
If your app needs to open external deep links (for example, to open URLs in the browser), Android 11 and higher requires you to declare supported schemes explicitly in your manifest:
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent>
</queries>
This allows your application to safely query and launch external URLs.
Handling notification links
Deep links are also used within HTML and Web Page notification types. To handle links clicked inside these notifications, declare the supported URL schemes in your manifest and define them in a resource file.
This functionality is available only when notifications are presented using the actito-push-ui module. If you handle notification presentation manually, you are responsible for processing clicked URLs within your own implementation.
Step 1 - Add Metadata in the Manifest
<meta-data
android:name="com.actito.push.ui.notification_url_schemes"
android:resource="@array/notification_url_schemes" />
Step 2 - Define the schemes
Create a resource file named notification_url_schemes.xml in res/values/ and add the supported URL schemes to it.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="notification_url_schemes">
<item>com.example</item>
<item>com.example2</item>
<item>com.example3</item>
</string-array>
</resources>
This configuration allows the SDK to intercept links matching any of the defined schemes and trigger a callback when clicked.
Step 3 - Implement the Lifecycle Listener
When a user taps a hyperlink within an HTML or Web Page notification, the SDK automatically invokes onNotificationUrlClicked() from ActitoPushUI.NotificationLifecycleListener. You can use this callback to handle the navigation logic for custom URL schemes:
class MainActivity : AppCompatActivity(), ActitoPushUI.NotificationLifecycleListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Register this activity as a lifecycle listener
Actito.pushUI().addLifecycleListener(this)
}
override fun onDestroy() {
super.onDestroy()
// Remove listener to prevent leaks
Actito.pushUI().removeLifecycleListener(this)
}
override fun onNotificationUrlClicked(
notification: ActitoNotification,
url: Uri
) {
// Handle the deep link according to your app’s routing logic
}
}