How to implement Deep-linking and deferred deep-linking in your app

What is deep linking ?

In the context of the mobile apps, deep linking consists of using a uniform resource identifier (URI) that links to a specific location within a mobile app rather than simply launching the app. Deferred Deep Linking allows users to deep link to content even if the app isn’t already installed. Depending on the mobile device platform, the URI required to trigger the app may be different.

android-deep-linking-2-638

Where to use ?

Sometimes at app promotions time we directly post a url on social networking sites and directly sends a url via SMS.
In this case two conditions can occur

1>User already installed that app.
If user have app in device then deep-linking works.

2>User haven’t app inside device.
In this case deferred deep-linking works

android-deep-linking-4-638

Where we use deep-linking and deferred deep-linking?

When you want to open the particular screen of item of your app then you can use this.
E.g. Suppose You are using facebook (on browser or app) , and you click on url posted by flipcart/snapdeal for any item detail then flipcart/snapdeal app opens with item’s detail.
>When we click url of youtube video from google or from anywhere, then video opens on youtube app.

Deferred_deeplinkingv3

How it works ?

In Android, it’s a simple configuration in the manifest. Just define intent filters in the app manifest, and make sure you have at least one intent filter per deeplinkable activity. The intent filter should have a data tag with at least the android:scheme attribute set. You also need to handle the intent in the activity.

1:- Add Intent Filters for Your Deep Links


* action
* data
* category

example :-

activity
android:name="com.example.android.GizmosActivity"
android:label="@string/title_gizmos"
intent-filter android:label="@string/filter_title_viewgizmos"
action android:name="android.intent.action.VIEW"
category android:name="android.intent.category.DEFAULT"
category android:name="android.intent.category.BROWSABLE"

data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="/gizmos"

data android:scheme="example"
android:host="gizmos"

intent-filter
activity

2:-Read Data from Incoming Intents.

example:-

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

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

Another code

In the below example we are opening different activities for different path/pathPrefix

as :-

data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="/gizmos"

path is /gizmos

data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="/video"

path is /video

data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="/songsDetail"

path is /songsDetail

When we install app(with above Added Intent Filters) then system save these url entries with activity(inside which we implement intent-filter), and on click on url , system suggest our app to open.

private void openDeepLink(Uri deepLink) {
String path = deepLink.getPath();

if ("gizmos".equals(path)) {
// Launch preferences
startActivity(new Intent(this, PushPreferencesActivity.class));
} else if ("video".equals(path)) {
// Launch the inbox activity
startActivity(new Intent(this, InboxActivity.class));
} else {
// Fall back to the main activity
startActivity(new Intent(this, MainActivity.class));
}
}

We can also get values from that url:-

https://www.your_url.com/apps/details?name=Himanshu

We will get the value of name as:-

String urltextboxname=data.getQueryParameter(“name”);

How deferred deep-linking works ?

Deferred deep linking improves a user’s first-time experience with your app and increases app engagement. For example, say that a customer clicks on a link with a promo code or other offer to install an app. After the app is installed, the best experience would be to direct the customer to the promo code or offer page within the app. Deferred deep linking sends the customer to the right page after installation. You can even access the promotional code to populate forms in your app.

>In order to place a user in the proper location or screen within an app, the deep link must be passed through the app store into the app at install. To do this, the install needs to be attributed to its source so the app developer will need to use an install matching attribution platform to connect the install to the link clicked.

In deferred deep-linking case url can be same

https://www.your_url.com/apps/details?name=Himanshu

but in this case app is not installed in device so this url will open in browser and url will redirect to market url with some data and then will be something like that :-

https://play.google.com/store/apps/developer?id=eBay+Mobile&hl=en&referrer=utm_source%3Dadwords%26utm_medium%3Dcpc

You can made your deferred url from here:-

https://support.google.com/analytics/answer/1033867?hl=en

In this case we have a install referral broadcast receiver in our app.
And when user install app after clicking the deeplinking url then url redirect to market url with some values .
and we get those values inside install referral receiver class from intent .

deferreddeeplinking

deferredeeplinkingexample

how_android_deeplink_works

Linchpin Technologies Pvt Ltd, a mobile app development company Noida , is globally recognised as a enterprise app development company
references :-

http://search-codelabs.appspot.com/codelabs/android-deep-linking#1

https://support.yozio.com/customer/portal/articles/1733104-deep-link-deferred-deep-link

for iOS.

https://tapstream.com/developer/deferred-deep-links/

Linchpin Technologies Pvt Ltd, a mobile app development company India , is globally recognized as enterprise app development company

9,636 total views, 7 views today

Share this OnShare on FacebookTweet about this on TwitterShare on LinkedInShare on Google+

Leave a Reply