Deep Linking
Deep linking enables seamless navigation to specific in-app content, enhancing user engagement by directing users to targeted screens within your Unity application. The AppTrove Unity SDK supports two types of deep linking: Normal Deep Linking (for users with the app installed) and Deferred Deep Linking (for users who install the app via a deep link). This section outlines the setup and implementation for both Android and iOS platforms.
Prerequisites
- AppTrove Unity SDK installed and initialized in your Unity project (see Installation and Initialization)
- A Trackier MMP account with access to the Trackier Panel
- Unity Editor 2019.4 or later
- For iOS: Xcode 12.0 or later
- For Android: Android API 21 (Android 5.0) or later
- Basic knowledge of C# scripting and platform-specific configurations (e.g.,
AndroidManifest.xml
, Xcode)
Overview
Deep linking redirects users to specific app content using URLs. The AppTrove SDK handles two scenarios:
- Normal Deep Linking: When the app is already installed, the deep link opens the app and navigates to the specified screen.
- Deferred Deep Linking: When the app is not installed, the deep link directs users to the app store. After installation, the SDK navigates to the specified screen upon first app launch.
Normal Deep Linking
Normal deep linking allows users with the app installed to open specific app screens directly via a deep link URL. Configuration is required for both Android and iOS.
Android Configuration
To handle deep links on Android, configure an activity in the AndroidManifest.xml
file to respond to deep link URLs.
Step 1: Create or Edit AndroidManifest.xml
- In Unity, create a custom
AndroidManifest.xml
file in theAssets/Plugins/Android
directory. - Add an activity with an intent-filter to handle deep links.
<activity
android:name=".Activity.FirstProduct"
android:exported="true">
<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:host="trackier.u9ilnk.me"
android:pathPrefix="/product"
android:scheme="https" />
</intent-filter>
</activity>
Example Deep Link URL
https://trackier.u9ilnk.me/product?dlv=FirstProduct&quantity=10&pid=sms
Step 2: Test the Deep Link
- Build your Unity project for Android (go to File → Build Settings, select Android, and click Build).
- Install the APK on a device or emulator.
- Open the deep link URL in a browser or via an ad to verify it opens the specified activity.
iOS Configuration
For iOS, configure Universal Links to enable deep linking, allowing the app to open directly from web URLs.
Step 1: Get App Bundle ID and Prefix ID
- Log into your Apple Developer Account.
- Navigate to Certificates, IDs & Profiles > Identifiers > App IDs.
- Select your app and copy the Prefix ID and App Bundle ID.
Step 2: Add IDs in Trackier MMP
- Log in to your Trackier Panel.
- Select your application and click the Action button.
- Navigate to UniLink in the Dashboard.
- Create a template by clicking the Action button in the header.
- Edit the template and add the Prefix ID and App Bundle ID under Link Behaviour (When application is installed).
Step 3: Configure Associated Domains in Xcode
- Build your Unity project for iOS (go to File → Build Settings, select iOS, and click Build).
- Open the generated
.xcodeproj
file in Xcode. - Select your project and target in Xcode.
- Go to the Capabilities tab and enable Associated Domains.
- Add the unilink subdomain from the Trackier MMP app settings in the format:
applinks:subdomain.unilink.me
.
Note: Trackier hosts the
apple-app-site-association
file to support Universal Links. Ensure the unilink subdomain is correctly configured in both Trackier MMP and Xcode.
Step 4: Test Universal Links
- Build and install the app on an iOS device or simulator.
- Open a Universal Link (e.g.,
https://yourbrand.u9ilnk.me
) in Safari to verify it opens the app.
Deferred Deep Linking
Deferred deep linking directs users to the app store if the app is not installed. After installation, the SDK navigates to the specified screen upon first app launch. This requires setting a callback to handle the deep link URL.
Steps to Implement Deferred Deep Linking
- Set a callback method on the
TrackierConfig
object usingsetDeferredDeeplinkDelegate
. - Initialize the SDK with the configured
TrackierConfig
. - Handle the deep link URL in the callback to navigate to the desired screen.
using UnityEngine;
using System.Collections;
using com.trackier.sdk;
using System;
public class NewMonoBehaviour : MonoBehaviour
{
void Start()
{
// Initialize SDK with Deferred Deep Linking
TrackierConfig trackierConfig = new TrackierConfig("abcf2270-xxxxxxxxxx-34903c6e1d53", "development");
trackierConfig.setDeferredDeeplinkDelegate(DeferredDeeplinkCallback); // Set callback for deferred deep linking
TrackierUnity.initialize(trackierConfig);
Debug.Log("AppKey Initialized");
}
void Update()
{
}
private void DeferredDeeplinkCallback(string deeplinkURL)
{
Debug.Log("Deferred deeplink reported!");
if (deeplinkURL != null)
{
Debug.Log("Deeplink URL: " + deeplinkURL); // Handle the deep link URL
// Add logic to navigate to the specified screen based on deeplinkURL
}
else
{
Debug.Log("Deeplink URL is null!");
}
}
}
Expected Outcome
When a user installs the app via a deep link, the DeferredDeeplinkCallback
method receives the deep link URL, allowing you to navigate to the specified content after the app launches.
Best Practices
- Test Deep Links Thoroughly: Test both normal and deferred deep links on Android and iOS to ensure correct navigation.
- Use Unique Schemes for Android: Choose a unique
android:scheme
value inAndroidManifest.xml
to avoid conflicts with other apps. - Secure Unilink Subdomain: Verify the unilink subdomain is correctly configured in Trackier MMP and Xcode to prevent Universal Link failures.
- Handle Null URLs: Add fallback logic in the
DeferredDeeplinkCallback
to handle cases wheredeeplinkURL
is null. - Log Deep Link Data: Use
Debug.Log
or similar logging to verify deep link URLs during development. - Comply with Privacy Regulations: Ensure deep link data handling complies with GDPR, CCPA, and other privacy laws.
Troubleshooting
- Deep Links Not Opening App (Android):
- Verify the
AndroidManifest.xml
intent-filter configuration matches the deep link URL structure. - Ensure
android:exported="true"
is set for the activity. - Test the deep link URL in a browser or via an ad.
- Verify the
- Universal Links Not Working (iOS):
- Confirm the
applinks:subdomain.unilink.me
entry is correct in Xcode's Associated Domains. - Check that the
apple-app-site-association
file is hosted by Trackier and accessible. - Ensure the Prefix ID and App Bundle ID are correctly set in Trackier MMP.
- Confirm the
- Deferred Deep Link Callback Not Triggered:
- Verify the
setDeferredDeeplinkDelegate
method is called beforeTrackierUnity.initialize
. - Test the deferred deep link by uninstalling the app, clicking the deep link, and installing via the app store.
- Check Unity Console logs for errors in the
DeferredDeeplinkCallback
.
- Verify the
For further assistance, refer to the Trackier Documentation Portal or contact Trackier support at support@trackier.com.