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
Related
I am trying to make Android deeplinking work only for specific urls e.g.:
https://books.com/book/nice-title-of-a-book
https://books.com/book/abc-for-dummies
So http://books.com/about keeps linking to the webpage
This configurations in my AndroidManifest.xml works and opens the correct page in my app. The issue is that this matches every page on books.com
<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="#string/custom_url_scheme" />
<data android:scheme="https" android:host="books.com" />
</intent-filter>
When I change the data part into:
<data android:scheme="https" android:host="books.com" android:path="/book/nice-book-1" />
or
<data android:scheme="https" android:host="books.com" android:pathPrefix="/book" />
or
<data android:scheme="https" android:host="books.com" android:pathPattern="/book/..*" />
to match only /book followed by a slug, it does not work a all.
I've already found many similar questions on Stackoverflow but they are either quite dated or not handle the situation where an url works with slugs.
Android Navigation Deep Link - Ignore Query
Intent filter using path,pathPrefix, or pathPattern
How to use PathPattern in order to create DeepLink Apps Android?
Does anyone have run into the same issues when matching only a few urls with slugs?
It took me a very long time to figure this out. So I'll answer my own question to save others precious time.
It turned out that when running an Android app on a device via Android studio
<data android:scheme="https" android:host="books.com" />
Is the only path that will work.
When using:
<data android:scheme="https" android:host="books.com" android:path="/book/nice-book-1" />
or
<data android:scheme="https" android:host="books.com" android:pathPrefix="/book" />
These will only work when using a SIGNED version of the app on your device. This probably because in your assetlinks.json there is a sha256_cert_fingerprints which can only be verified when a signed app is used.
In my android app code Manifest file contains following Intent filter for handling a Link in the app but doesn't work
<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="safimoney.com"
android:pathPrefix="/.*/transactions/request-money/confirm/.*" />
</intent-filter>
test it with link generated from web "https://safimoney.com/en/transactions/request-money/confirm/0CnpXE7u5hXRD1JVcZM2APHcYElKZvBZs8GeqimJ" but it doesn't ask for an open link in the app.
If you want your app to open a link, use below code.
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
It will ask to select browser while opening this link.
You wanna do a Deep Link, right?
<intent-filter>
<data
android:host="open"
android:scheme="companyName" />
<data
android:host="companywebsite.com"
android:scheme="http" />
<data android:scheme="https" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
I would suggest for you take a look in Branch.io for link-app solutions.
But if you wanna make a webView inside your app this tutorial can help you.
This is one of the cases where developer.android website has everything that you need, even code examples. Just need to ready with a lot of attention. Hope it helps
EDIT
About your data, looking on android developer website, this should be the better way to set:
<data
android:scheme="https"
android:host="safimoney.com"
android:pathPrefix="/en/transactions/request-money/confirm/" />
But even after this you should add a data like this
<data android:scheme="safimoney"
android:host="/en/transactions/request-money/confirm/" />
I'm trying to get deep linking working in my app. I'd like to detect three url types: one with https (for example https://my-app.com), one with http (http://my-app.com) and one without any scheme (my-app.com). First two works just fine, but how to get third one working?
So far i get this code:
<intent-filter>
<data
android:host="my-app.com"
android:scheme="http" />
<data
android:host="my-app.com"
android:scheme="https" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
I tried with <data android:scheme="my-app.com" />, but no luck.
Thanks in advance for any hints.
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>
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"