Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android URI schemes vs App Links

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

like image 551
Igor Kostenko Avatar asked Jul 18 '17 14:07

Igor Kostenko


People also ask

What is the difference between deep links and app links?

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.

What is URI scheme in Android?

Android URI Scheme and Intent FilterIt allows the developer to register their app for a URI (uniform resource identifier) in the operating system for a specific device once the app is installed. A URI can be any string without special characters, such as HTTP, pinterest, fb or myapp.

What is app URI scheme?

An app: URI provides a means to retrieve a file from within a package using similar semantics to performing a GET request over [HTTP]. This allows the app: URI scheme to be used with other technologies that rely on HTTP responses, such as [XHR].

What are app links called?

Android App Links: They are HTTP URLs that can be used to link to content inside a native app if it is installed on the device. For example, you have the URL https://example.com/product/red-shoes and the same content is also available on your native app.


1 Answers

URI Scheme Deep Linking (Android 4.2)

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 (Android 6.0)

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.

Requirements

  • you must have a functional website
  • the user must be on Android 6.0

Configuration

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:..."]
    }
}]

Deferred Deep Linking

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.

like image 160
clayjones94 Avatar answered Sep 30 '22 14:09

clayjones94