[MUSIC PLAYING]
SABS: Users want to get content quickly,
and deep links are here to help.
We'll cover their common uses, how, and when to use them.
One example, which we will work through the video,
is an app we call Droid Food, a restaurant
app where the user chooses options for their restaurant.
Before we begin with deep links and its details,
let me explain what we mean by links.
In a nutshell, a link is a string of characters
that will take us someplace.
This string of characters take the form of a Uniform Resource
Identifier, or a URI.
A URI is composed of various elements.
For our purposes, we will focus on these three--
scheme, authority, and path.
Here are the different deep link types
you can create in an Android app--
deep links which handle all URIs and have custom schemes, web
links, with handle HTTP and HTTPS schemes,
and Android app links, which are web links that
use the autoVerify attribute.
As shown in this picture, we can say to a certain extent
that each type is a special case of the previous one.
There are important sections which we will cover over
the course of the video.
Let's begin with deep links.
For a deep link, what URI components do we need?
Scheme-- you can use a standard scheme, such as HTTPS,
or you can use a custom one.
Authority-- here it is recommended
you have a domain structure, because it makes
ownership of the link clear.
Path-- you can use this component in your app logic
to send a user to a particular screen.
Here we have a link for our restaurant app
to show our different locations.
Using a custom scheme in your deep links
can help your users reach your in-app content effectively.
However, deep links don't have a centralized registry
of ownership, so any app can sign up
to handle a particular deep link.
If your device contains multiple apps that
handle the same deep link authority,
the system shows a disambiguation dialog
when we follow a deep link.
There are some exceptions on the scenario
related to Android versions.
Please check our blog posts in the description
for more details.
There are various schemes that can
help with several built in intents,
including geolocations, text messages, and file content.
When a user clicks on a deep link,
they can be directed to any activity in your app,
depending on the path.
Following our Android app example,
we have our Droid Food app with three activities.
When a user selects the location link,
they will be redirected to the LocationsActivity.
Navigation is a very interesting topic
and very useful with deep links.
We will discuss it in a future video of the series.
There is also the MAD video series
that shows how to do this with Jetpack navigation.
Please check the link in the description.
Let's continue with web links.
You may have a website which has the same content of your app,
and you want to share a link between the people who have
your app and those who don't.
What URI components do we need for a web link?
Scheme-- this must be either HTTP or HTTPS.
Authority-- for a web link, the authority
is your web host name.
Path-- this component is optional and is mostly related
to your website.
Here we have a web link for a page that lists all
of our restaurant locations.
Let's review what's happened in Android 12,
because there has been changes since its previous versions.
Starting from Android 12, all web links
will open in the browser, unless the website and Android
app have configured the association between them that
is needed for Android app links.
For more information on these changes,
please check our documentation in the link
down in the description.
In a previous version of Android,
the disambiguation dialog might appear
if there is multiple handlers for this link, like browsers
or other apps.
Let's finish with Android app links.
What URI components do we need for Android app links?
Scheme-- since they are a subset of web links,
these must have the HTTP or HTTPS schemes, authority,
and path.
These are similar to web links.
Android app links achieves the user's best results
with user experience, because when the app's installed
and the app link is click, the user
is guaranteed to go to the app, and no disambiguation dialog
appears.
There are some extra things we need to do in order
to create an Android app link.
autoVerify attribute.
This attribute lets your app to be the default handler
for a given type of link.
Association.
There needs to be an association between the web
page and the Android app.
This will take the form of a JSON file called
assetlinks.json that is stored in a well-known directory
under the root of your website's domain or authority.
Please make sure your website responds to the URL
so that users without the app still
end up at the right place on your website.
Let's explore a few situations where
Android app links are useful.
Let's say you want to invite a friend for lunch
and they are curious about the menu.
You just share the link, and since they
have the app installed, they can see
what's on the menu directly in the app.
Imagine you want to share some coupon
code for 15% of your dinner delivery menu.
That's a great deal.
Just share the link with your customers
so the app will directly apply the coupon at checkout.
Let's have a quick mention about security.
Before Android 12, if you have a link which
failed a verification, the disambiguation dialog
will appear for all of your links.
This will leave users open for an app that
can handle those links in their manifest
and leave your users open for a potential risk.
Be careful when generating links with sensitive information.
If you need to include it in URLs,
consider using opaque tokens that can be invalidated
when they are no longer needed.
Users can change the link handling behavior
on their device, which means links can be intercepted
by other apps or browsers.
People can also copy and paste links anywhere, so make sure
you designed your links with this in mind.
Users need to be notified when a link in your app
triggers an action with a side effect,
such as sending them over outside of the app.
With this introduction, we hope you
are more confident about using deep links to take users
where they want to go.
If you want to go deeper into the implementation
details, verification, and best practices,
please check the second video, Deep Links From 0 to Hero.
And don't forget to subscribe to the Android developer
channel for more.