My requirement is, There is an advertisement in an email for a shoe, if I click on that ad, it should open my app directly and take me to corresponding page without asking any available option like web browser, etc.
I tried Deep linking fundamental, But I don't know how to create deep links, from where I can get custom scheme(eg. testlink://test).
for eg. google play scheme is market://details/
Thanks in advance
To enable Google to crawl your app content and allow users to enter your app from search results, you must add intent filters for the relevant activities in your app manifest.
refer https://developer.android.com/training/app-indexing/deep-linking.html
https://developers.google.com/app-indexing/android/app
There are actual several questions at play here:
1 - You need to know how to create a URI scheme(the testlink:// protocol you reference).
2 - You need to make your app do something when the end user clicks on the deep link.
To begin at the beginning, you don't "get" the custom scheme from anywhere, you create a URI scheme as part of setting up your app. There is no real standardization as to what that scheme should be (despite some attempts).
The question of how to do this have been answered elsewhere (How to implement my very own URI scheme on Android and in the android docs).
And I actually just published a blog post with some suggestions on how to optimize that URI scheme (https://blog.branch.io/creating-uri-schemes-for-app-content-discovery).
The second question is easier. Once you have that scheme in place, a user who
(a) clicks on a link that matches your scheme
(b) has your app installed and
(c) doesn't have some other app installed which uses the same scheme and which they've already set as the default for that scheme
will be launched directly into your app to the exact location / experience that you defined when you were setting up your intent filters.
Now if you want your deep links to work for users who don't already have your app installed you'll need to use a deferred/contextual deeplinking service. Obviously I'm inclined towards Branch.io since I work for them, but I work for them because I think they have the best offering.
Regarding your last requirement, that there be no browser pop in between, the browser pop is usually part of the flow because it allows a deep linking service to pass some information to their servers about the user on click so that if the user does not have the app they can be directed to the app store and if they do have the app it can be launched by invoking your URI scheme. If you want to do any sort of matching between click and install for users who do not already have the app or pass any info from the click to the app once it launches it been simply unavoidable until now. Universal links on iOS (new in iOS9) change that. They can be invoked directly without needing to go through the browser and pass data directly into the app being launched, which is a pretty big deal. Google is expected to announce an equivalent for Android in the very near future. The setup is a bit intense, but worth it for the improved user experience.
Good luck!
Related
Objective : I have 2 apps (Say A & B).
Case 1:
When app B is installed and I launch a page (say product page) on app A it will land to same product page of app B.
Case 2:
When app B is not present and I launched it from app A it will land to play store and and after installing it will open the same launched page of app A in app B.
I have followed https://developers.google.com/analytics/devguides/collection/android/v4/campaigns#google-play-url-builder
but unfortunately didn't get any success.
I want to create it without any third party library like branch/facebook etc.
Please suggest something.
What you're describing is called Deferred Deep Linking (Deep Linking refers to using a link to open your app directly to a specific piece of content, and Deferred means that it works even if the app isn't installed first).
Unfortunately there's no native way to accomplish this on either iOS or Android. The Google Play INSTALL_REFERRER could work in theory, but it's unreliable and often gets delivered too late (i.e., seconds to minutes of waiting) to provide a good UX. URL schemes don't work, because they always fail with an error if the app isn't installed. Universal Links in iOS 9+ and App Links on Android 6+ at least don't trigger an error if the app isn't installed, but you'd still have to handle redirecting the user from your website to the App Store. You still can't pass context through to the app after install with Universal Links and App Links, so you wouldn't be able to send the user to the correct item.
To make this work, you need a remote server to close the loop. You can build this yourself, but you really shouldn't for a lot of reasons, not the least of which being you have more important things to do. Free services like Branch.io (full disclosure: they're so awesome I work with them) and Firebase Dynamic Links exist precisely to handle all of this for you, and we have a number of partners who build app-to-app connections like this.
I'd love to hear any feedback on why you are hesitant to use a third-party library!
I want to implement deferred deep linking in my android app. My understanding is I need to provide a url and when user opens the url, it will direct user to the app or to play store if the app has not been installed. From my research, seems Android is able to resolve deferred deep linking by default. But my question is where is the URL from? Does Google have any url builder to generate it for me or do I need to have a website and write some code for the url?
Firebase Dynamic Links seems to be the official Android way to support the deferred deep link that will send user across the installation UI if needed. It also works with iOS and Web.
The answers and comments so far are all referring to normal deep linking. None of them will get you deferred deep linking (i.e., the ability to deep link even when the app is not installed yet and the user needs to first visit the Play Store to download it).
Vanilla iOS does not support deferred deep linking at all. Android can do it with the Android Google Play referrer, but it is unreliable and doesn't work at all from Chrome.
To do this, you'll likely want to investigate a free third-party service like Branch.io (full disclosure: I am on the Branch team). The Branch platform abstracts all the technical details and edge cases away, so all you need to worry about is defining a set of key/value parameters (for example: articleID: story123) when you create a link. Branch makes sure those parameters are returned to you inside the app the first time it launches after the user clicks the link, whether or not the app was installed when the link was clicked. You can then use the values to route/customize however you wish.
The url comes from any app or the user. Its just a normal app in the form http://example.com/path. THe magic is that your manifest registers an intent filter for the http scheme and the example.com/path path, and Android will take any intent that has an ACTION_VIEW for that url to your app. If your app isn't installed, since its an http url it falls back to the browser. If the url happens to go or redirect to the play store, then it gets you that behavior as well.
You can try using this scheme(to be sent to the user):
intent://details?id=X&url=Y&referrer=Z#Intent;scheme=market;action=android.intent.action.VIEW;package=com.android.vending;end";
X: Package name of the App
Y: Deep link scheme which should be defined in the App's manifest. (Please refer this) Here, they have used this URL as an example: "http://www.example.com/gizmos" , therefore Y should be replaced by this URL.
Z: Can be any data which you want to pass to the App via Google Play. Please take note that any data which you pass should not be '&' separated because the original parameters are itself '&' separated.
From what I experimented, this URL is understood by the browser and it redirects you to the App based on the package name and the deep-link scheme. Else it takes you to the Google Play.
PS: The Google Play makes a broadcast to the app. So make sure you receive the broadcast in a receiver.
Below is my scenario:
If the app is installed, launch the app pass a referrer data and handle it inside the app.
If the app is not installed , direct to google play install the app handle the referrer data.
I am able to achieve first case
For scenario 1 , I have
link 1:
http://www.xxx.co.in/main?id=4&referrer="+referrer
My activity is configured correctly and I am able to achieve scenario 1.
For scenario 2, I have
final String url = "http://www.xxx.co.in/main?id=4&referrer="+referrer+"#Intent;scheme=market;action=android.intent.action.VIEW;package=com.xxx&referrer="+referrer+";end";
This I am not able to achieve, If the app is not installed, instead of directing me to google play, it tries to open www.xxx.co.in/main.... in browser.
What is wrong here and how to achieve this.
NOTE: I do not want to host my own server hence redirecting from a remote server is out of scope.
Are you opening this link in the native Android browser, or Chrome? That looks like an Intent link, so it will only work in Chrome even if it is formatted correctly. However, Chrome doesn't support the Android Play referrer
To be honest, this sounds like a perfect use case for an external deferred deep linking service like Branch.io (full disclosure: I'm on the Branch team). Branch links do exactly what you're describing, and they do it on all browsers while saving you from the headache of needing to handle all the different variations. All you need to worry about is defining a set of key/value parameters (for example: articleID: story123) when you create a link, and Branch makes sure those parameters are returned to you inside the app the first time it launches after the user clicks the link, whether or not the app was installed when the link was clicked. You can then use the values to route/customize however you wish.
Google suggests the way to link to the Google Play Store is:
market://details?id=<package_name> if you are in an application,
and
http://play.google.com/store/apps/details?id=<package_name> if
you are on a webpage.
When we followed this strategy, we got a toast of "No such app found", even though the Google Play Store had the app we were looking for.
This turned out to be caused by the competition of two market handlers: F-droid (Open source marketplace) and Google Play Store. I found there were multiple by looking at the package manager for the intent resolvers.
I only ever want apps in the Google Play Store to be linked to by my app.
Is there a way to force that app to respond to my market://[...] link?
Other strategies suggest attempting one approach, and if that fails, trying the http://[...] link. (The linked solution failed for me, as no exception was thrown.)
What will go wrong if I always link via the http:// method? I.e., skip the market:// link, and use http:// directly in the app. Will this decision come back to haunt me later?
I'm not linking to open source apps, I'm linking to Google play store ones
No, you are trying to open a Uri with an ACTION_VIEW Intent. In principle, the user is welcome to handle that request with anything they want, just as they can open a PDF with whatever app they want. This is one of the few places in Android where I think that it is justified to try to force the issue and steer the user to a particular app and away from whatever they might normally choose.
I only ever want apps in the Google Play Store to be linked to by my app. Is there a way to force that app to respond to my market://[...] link?
If you are the one calling startActivity() for this Uri, you could wrap the Intent in Intent.createChooser(). This would force the chooser dialog to appear, avoiding the default, if there is more than one activity matching the Intent. This is the safest and most stable approach, as it does not depend on any details of the Play Store itself.
You could call setComponent() on the Intent and provide a ComponentName that theoretically points to the desired activity. That's one Google refactoring away from breaking.
You can try to see if setPackage() will limit Intent resolution to your desired app. Once again, if Google decides to switch to a different package as its entry point to the Play Store, you would have to adapt. And I'm not sure if setPackage() is honored in this scenario.
Other strategies suggest attempting one approach, and if that fails, trying the http://[...] link. (The linked solution failed for me, as no exception was thrown.)
Yes, because your problem isn't that there's no match, but that there are multiple matches, and another choice was made instead of the one that you want.
What will go wrong if I always link via the http:// method? I.e., skip the market:// link, and use http:// directly in the app.
This doesn't really solve your problem, insofar as there are other apps that handle that Intent, like Web browsers.
I'd like to launch my app with input parameters from a Web link, or fallback on going to the market page for my app, so that user could install it.
The question is how to have the user install the app and launch it from the market app, but with the input parameters.
Something along the lines of the following:
market://search?q=<query>¶ms=start?a=foo&b=bar
You can construct a URL that will start your app from the device's browser, and to a limited extent, provide extra parameters in it.
Do thing!
You'll need to enable the BROWSABLE filter for your Activity.
This is kind of bad form, though since any non-Android browser that runs across this link will react badly to it.