HomeAppVirality DocsAdvanced ConfigurationsConfigure Deep LInk

Configure Deep LInk

Deep Linking provides a mechanism to open an installed application to a specific resource. As we navigate to a web page with the help of URL, the same way we can also navigate to a specific screen inside a mobile app with the help of a deep link URI. Deep Links are links to some specific resource inside a mobile app, which when clicked upon loads up the particular screen and resource.
With the help of AppVirality deep link users will be navigated to the play store link of your app in case they don’t already have it installed on their device.

How to configure deep link on Android:


Follow the below steps to configure deep link for your Android app:

1. Add Intent Filters to intercept link clicks

To intercept a deep link click, add an intent filter with the below elements and attribute values in your app manifest.

i. <action>
Specify the ACTION_VIEW intent action so that the intent filter can be reached from Google Search.

ii. <data>
Add one or more <data> tags, each of which represents a URI format that resolves to the activity. At minimum, the <data> tag must include the android:scheme attribute. In addition, you can include the android:host attribute to specify how the URI begins, here you can give value as http for HTTP based URI or any host name of your choice.

iii. <category>
Include the BROWSABLE category. It is required in order for the intent filter to be accessible from a web browser. Without it, clicking a link in a browser cannot resolve to your app.
Also include the DEFAULT category. This allows your app to respond to implicit intents. Without this, the activity can be started only if the intent specifies your app component name.

The following XML snippet shows how you might specify an intent filter in your manifest for deep linking. The URIs “example://gizmos” and “http://www.example.com/gizmos” both resolve to this activity.

 
 <activity
    android:name="com.example.android.GizmosActivity"
    android:label="@string/title_gizmos" >
    <intent-filter android:label="@string/filter_view_http_gizmos">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
        <data android:scheme="http"
              android:host="www.example.com"
              android:pathPrefix="/gizmos" />
        <!-- note that the leading "/" is required for pathPrefix-->
    </intent-filter>
    <intent-filter android:label="@string/filter_view_example_gizmos">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Accepts URIs that begin with "example://gizmos” -->
        <data android:scheme="example"
              android:host="gizmos" />
    </intent-filter>
</activity>

Once you’ve added intent filters with URIs for activity content to your app manifest, Android is able to route any Intent that has matching URIs to your app at runtime.
 

2. Read data from incoming intents

Once the system starts your activity through an intent filter, you can use data provided by the Intent to determine what you need to render. Call the getData() and getAction() methods to retrieve the data and action associated with the incoming Intent. You can call these methods at any time during the lifecycle of the activity, but you should generally do so during early callbacks such as onCreate() or onStart().

Here’s a snippet that shows how to retrieve data from an Intent:

 
 @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Intent intent = getIntent();
    String action = intent.getAction();
    Uri data = intent.getData();
}

 

How to configure deep link on AppVirality dashboard:


Configuring deep link on AppVirality dashboard is very simple and straight forward, please follow the below steps to do so:

1. Select App Details from left side menu.
2. Click on the More button and select Advanced Settings from the options for the campaign, for which you want to configure the deep link.
3. Click on + icon under Advanced Url Settings to include a new attribute.
4. Select Android Deeplink from the dropdown menu and provide the deep link URI in the adjacent text field. A URI is ususally a combination of scheme and host, for example http://www.host.com or scheme://host.
 

 

How to test Android deep links:


You can use the Android Debug Bridge with the activity manager (am) tool to test that the intent filter URIs you specified for deep linking resolve to the correct app activity. You can run the adb command against a device or an emulator.

The general syntax for testing an intent filter URI with adb is:

 
 $ adb shell am start -W -a android.intent.action.VIEW -d <URI> <PACKAGE>

For example, the command below tries to view a target app activity that is associated with the specified URI.

 
 $ adb shell am start -W -a android.intent.action.VIEW  -d "example://gizmos" com.example.android

 

How to configure deep link on iOS:


Follow the below steps to configure deep link on iOS:

1. Go into your app’s info.plst file.
2. Add a Row to this and call it “URL types”.
3. Expand the first item in “URL types” and add a row called “URL identifier”, the value of this string should be the reverse domain for your app e.g. “com.yourcompany.myapp”.
4. Again, add a row into the first item in “URL types” and call it “URL Schemes”.
5. Inside “URL Schemes” you can use each item as a different url you wish to use, so if you wanted to use “myapp://” you would create an item called “myapp”.

Now you’ve registered the URL with the app, you can start the application by opening a url with the custom scheme. For example, >myapp://, myapp://a/random/path, myapp://?foo=1&bar=2

This url will send a message to the UIApplicationDelegate so if you want to provide a custom handler for it, all you need to do is provide an implementation for it in your delegate.

Something like this:

 
 - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
  // Do something with the url here
 }

Most people will want to parse the URL and store it in the NSUserDefaults, here is a example of how you could do that:

 
 - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
  if (!url) { 
    return NO; 
  } 
  NSString *URLString = [url absoluteString]; 
 }

 

Was this article helpful to you? Yes No