Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: app linking - supporting only certain paths?

I want to setup app linking for my app but only for it to be active on certain paths. In other words, in my manifest:

<intent-filter  android:autoVerify="true">
<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.mydomain.com/[mypath]" />
<data android:scheme="https" android:host="www.mydomain.com/[mypath]" />
</intent-filter>

I don't want every url that has my domain to open the app - they can open in the browser as usual. I only want urls that include the specific subpath to open in the app. Is this pattern allowed or is it "all or nothing" for app linking?

Link to the developer docs: http://developer.android.com/training/app-links/index.html

like image 620
Jon Avatar asked Apr 02 '16 15:04

Jon


People also ask

What is difference between app link and deep link?

When a user click an URL, it might open a dialog which asks the user to select one of multiple apps handling the given URL. On the other hand, An Android App Link is a deep link based on your website URL that has been verified to belong to your website. When user clicks that URL, it opens your app.

Does Android have universal links?

Android App Links (sometimes referred to as Universal links) are HTTP URLs available on Android 6.0 and higher, that help in bringing your users directly to your Android app. It contains the autoVerify attribute that allows your app to designate itself as a given type of link.

What is deep linking in Android?

In Android, a deep link is a link that takes you directly to a specific destination within an app. The Navigation component lets you create two different types of deep links: explicit and implicit.

How do I make a deep link for an app?

In the Link Settings and Redirects section, after you enable the link for iOS, Android, or both, fill out the following fields: "If the app is not installed go to" (this is the fallback redirect) "If the app is already installed, go to: (deep link)" "After installation, go directly to: (deferred deep link)"


1 Answers

You can have special paths, but you can't/shouldn't have them appended to the host.

You should have

<data android:scheme="https" android:host="www.mydomain.com" />

And from there you can use the android:path android:pathPattern or android:pathPrefix to create special patterns.

For example,

<data android:scheme="https" android:host="www.google.com" android:path="/en/index.html"/>

would only catch the url "https://www.google.com/en/index.html"

like image 55
craya Avatar answered Oct 14 '22 08:10

craya