Deep Link in Your Android Mobile App

A deep link is a link that goes not only to your app, but to a specific piece of content within your app. For more information, see Add Deep Links to Your App Ad.

You can support deep linking by using Android App Links or by using Custom URL Schemes.

Prerequisites

Before you can support Android App Links in your Android mobile app, you must satisfy the following prerequisites:

After you meet the prerequisites, there is no additional work to support Android App Links. You can start using your website URLs in your app ads and catalogs.

Support Custom URL Schemes in Your Mobile App

Step 1: Add Deep Linking Settings

In the App Dashboard add deep linking information for your app. Navigate to Dashboard > Settings > Android.

  • For ClassName find the name of the launch activity in the file AndroidManifest.xml. The class name should take the form com.example.androidapp.MainActivity.

Step 2: Deferred Deep Linking (Optional)

Deferred deep linking allows you to send people to a custom view after they install your app through the app store.

You must use deferred deep linking if you target people who did not install your app yet. If you are only targeting people who already installed your app, you do not need to add deferred deep linking.

The Facebook SDK for Android includes the product App Links, which enables you to support deferred deep linking in your app. In addition to your deep link implementation, just add the following code to your app to handle deferred deep links.

If you follow the GDPR compliance in GDPR Compliance in FB SDK Best Practices for GDPR Compliance, re-enable automatic SDK initialization first after an end user provides consent before fetching a deferred link.

Code to handle deferred links:

AppLinkData.fetchDeferredAppLinkData(this, 
  new AppLinkData.CompletionHandler() {
     @Override
     public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) {
         // Process app link data
     }
 }
);

Code to re-enable automatic SDK initialization, if necessary:

// Get user consent
FacebookSdk.setAutoInitEnabled(true);
FacebookSdk.fullyInitialize();
AppLinkData.fetchDeferredAppLinkData(this, 
  new AppLinkData.CompletionHandler() {
     @Override
     public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) {
         // Process app link data
     }
 }
);

Step 3: Verify Deep Link Setup

You can verify your Facebook SDK and deep link setup within our App Ads Helper in the tools & support section. We recommend verifying your setup before you start running deep link ads.

Verify Deep Link Setup

If you have select App Installs as your objective you can add a Deferred Deep Link.

In the Ads Manager, select New AdSet and scroll to Ad Creative. Add your deep link or a URL with Facebook App Links metadata implemented to take users to a specific location in the app after installing.