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
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"
Related
I am attempting to implement deep links within my Instant App, and keep running into issues that seem to be coming from something to do with the base application. Currently, the error I'm receiving from the Play Console states:
You should have at least one active installed app APK that mapped to
site 'example.site.com' through a web intent-filter.
I do have an intent-filters set up in both the instant app and in the full base app. The intent-filters in the base application look like this:
<intent-filter>
<data
android:scheme="http"
android:host="example.site.com"
android:pathPattern="/test/app/" />
</intent-filter>
<intent-filter>
<data
android:scheme="https"
android:host="example.site.com"
android:pathPattern="/test/app/" />
</intent-filter>
And the intent-filters in the instant app module's manifest look like this:
<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="https"
android:host="example.site.com"
android:pathPattern="/test/app/" />
<data
android:scheme="http"
android:host="example.site.com"
android:pathPattern="/test/app/" />
</intent-filter>
With the instant app manifest also containing a default url, set up within the activity tag.
I'm not sure what I am missing here. I have set up the intent filters as I've seen elsewhere on the web, in Google's documentation, and in other forum posts where I've seen people encountering issues with this process. I've also hosted the assetlinks.json file in the .well-known directory on my domain, and verified that it is correct and accessible using Google's verification API. Does anyone know what the issue causing this error may be? Thanks!
From what I have read in the documentation you need to make sure that you use an intent-filter with autoVerify, action and categories for the app as well. In your example you can simply copy & paste the intent-filter that you are using in the instant-app to your full app.
In case you are using string resources for scheme, host or pathPattern I would try to avoid this and directly enter your values in the manifest instead.
e.g. (crafted from your post)
<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="https"
android:host="example.site.com"
android:pathPattern="/test/app/" />
<data
android:scheme="http"
android:host="example.site.com"
android:pathPattern="/test/app/" />
</intent-filter>
I want to put deep linking with all the link looking like this :
https://myapp.com/*/*/quiz.html
How can I do that ? I try this intent-filter in my Manifest but the pathPrefix is not working :
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="myapp.com"
android:pathPrefix="/.*/.*/quiz\\.html"/>
</intent-filter>
Without the android:pathPrefix it's working but it's opening all the links from https://myapp.com.
You have to use android:pathPattern in your data element.
<data
android:host="myapp.com"
android:pathPattern="/.*/.*/quiz.html"
android:scheme="https" />
Then you can set any url pattern you want to open in your app. Read documentation . Also, here is good explanation about how it works.
I have a activity that apply intent filter to open deeplink, this is my intent filter :
<intent-filter android:autoVerify="true">
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.example.com"
android:pathPattern="/..*"
android:scheme="https" />
</intent-filter>
my problem is, when user open a link i.e "www.example.com/somepage" from messaging apps e.g Hangout,Whatsapp, Android app chooser doesn't display may apps in its list, it just show all browser app in the options. But when user put "https://www.example.com/somepage" in a message then it works, Android show my app in its App chooser to open the link.
It also doesn't work When I try to remove android:scheme="https" from my intent filter.
is there anyone has same problem and have a solution?
Any help really appreciated.
This is expected behavior.
What the following snippet does is register your app as a handler for the URL scheme https://
<data
android:host="www.example.com"
android:pathPattern="/..*"
android:scheme="https" />
This means your app will be offered as an option for any link beginning with https:// and containing www.example.com. The string www.example.com/somepage doesn't qualify, as it is missing the https:// part.
You could try adding a second filter for http:// links. I'm not sure if Android automatically infers that as the scheme for web links without a scheme specified, so it's possible this could resolve the issue.
<intent-filter android:autoVerify="true">
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.example.com"
android:pathPattern="/..*"
android:scheme="https" />
<data
android:host="www.example.com"
android:pathPattern="/..*"
android:scheme="http" />
</intent-filter>
My App is able to respond to any link in the browser visiting example.com with the following code. My question is, how can I program my app only to respond to
"http://example.com/#push/...".
I have to implement it this way, because only if the link contains the specific path, it should be possible to open the link with my app. Not in general. Another possible solution would be to allow any URI, but that one. So my App respond to any link but one.
<intent-filter>
<data
android:host="example.com"
android:scheme="http" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
I tried to add a pathPattern, but that results in not opening the link anymore:
<data
android:host="example.com"
android:pathPattern=".*push.*"
android:scheme="http" />
You should try with
<data
android:host="example.com"
android:pathPrefix="/#push/"
android:scheme="http" />
This way you can check only the initial part of the path.
Remember to include the leading / since it is a path segment.
The official documentation has a couple of examples on using the element:
http://developer.android.com/guide/topics/manifest/data-element.html
When any video url is clicked, on the android phone, I want my application to be displayed in popUp, which says, do you want to play the link using, chrome, or myApp..
I want this to happen only for specific Video links, like Youtube video URLs only. In short my application will work as an browser only for specific video links.
How should I achieve this.
Look into Intent Filters. You can use them to register your app to handle certain file types or specific url schemes.
<activity android:name=".YourActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="http" android:host="www.youtube.com" ></data>
</intent-filter>
</activity>
You might also want to use the same scheme for https and mobile, do not forget it ;-)
<data android:host="www.youtube.com" android:scheme="http" />
<data android:host="www.youtube.com" android:scheme="https" />
<data android:host="m.youtube.com" android:scheme="http" />
<data android:host="m.youtube.com" android:scheme="https" />