Android App Links works only from Android 6.0, unlike Deep Links from Android 4.2 but what the difference in behavior and coding?
I read the documentation but did not see the difference.
Deep Links: https://developer.android.com/training/app-indexing/deep-linking.html
App Links: https://developer.android.com/training/app-links/index.html
The standard URI scheme deep linking (Android 4.2) allowed developers to register an app for URI scheme i.e. pinterest:// and when a user clicked this link and had the app installed, the app would open. If the app was not installed, it would produce a 'Page Not Found' error.
It works by registering an app to respond to a given URI via the intent filter in the manifest.
<intent-filter>
<data android:scheme="your_uri_scheme" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
You would then handle the link by grabbing the intent string from the given activity.
Uri data = this.getIntent().getData();
if (data != null && data.isHierarchical()) {
String uri = this.getIntent().getDataString();
Log.i("MyApp", "Deep link clicked " + uri);
}
NOTE: If the user was coming from Chrome you would need to include separate handling. Chrome will not throw an error if the app is not installed, it will take you to the Play Store or (Optionally) provide you with a fallback URL
App Links were introduced to replicate the functionality of iOS Universal Links. App Links are a simple way to turn website links into App Links. Therefore, if a normal HTTP/HTTPS link is clicked and the corresponding app is installed, it will open immediately. If the app is not installed, a fallback web link is provided.
In the case of App Links your manifest is going to look slightly different.
<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="yoursite.com" />
<data android:scheme="https" android:host="yoursite.com" />
</intent-filter>
You then must register your website to handle App Links. You need to create an assetlinks.json file and host it on your website at yoursite.com/.well-known/assetlinks.json
/.well-known/assetlinks.json
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "io.branch.branchster",
"sha256_cert_fingerprints":
["14:6D:E9:..."]
}
}]
Unfortunately, neither of these methods support deferred deep linking, which is the ability to deep link to content inside the app when the app has not been installed yet. This is an important user experience for on-boarding new users so I suggested using a third-party like Branch (full disclosure I work for Branch) or Firebase. They will handle all of the functionality and edge cases, as well as, include other functionality like deep views and app banners if that's something you're interested in.