Android app links

Android App Links allow an application to designate itself as the default handler of a given type of link. For example, clicking a URL in an email would open the link in the designated application. This guide will show you how to enable Android App links support for your cidaas-registered application.

This guide will show you how to enable Android App links support for your cidaas-registered application.

If your using Android Studio(version above 2.3) to develop your app then you can use App Links Assistant tool to configure app links to your app.

Refer developer.android.com, to find steps to use App links Assistant.

If you want to manually configure App links to your application, then follow the below steps.

There are three steps to configure your domain to use app linking:

  • Configure the manifest to receive intents
  • Add code to your app’s activities to handle incoming links.
  • Associate your app and your website with Digital Asset Links.

Configure manifest

1. Choose the Activity which you want to open up when the incoming link is clicked.

2. Inside your AndroidManifest.xml, locate where the selected Activity is defined.

3. Within the Activity definition, insert the intent filter provided below (make sure to replace example.com with your real custom domain). Be sure to add this as its own separate intent filter:

  <application>
        <activity android:name=".SplashActivity">
        <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.com"
                android:path="/shop" />
          </intent-filter>
          </activity>  
  </application>
  • host : domain name of your website

  • path : The incoming link's URL must match the path component exactly, in order to launch the activity. If the path is set to /shop, for example, https://www.example.com/shop will be considered a match. A URL of https://www.example.com/shop/books, however, will not be considered a match.

  • pathPrefix : The specified path is only considered as the prefix. Additional path components may be included after the /shop component (for example http://www.example.com/shop/books will still be considered a match).

  • pathPattern : Allows the path to be specified using pattern matching in the form of basic regular expressions and wildcards, for example /books/*/[e-E]nglish/*

    Similarly, you can add mutiple intent-filters for your activity as per the requirement.

4. Now you have to verify whether autoVerify option is enabled to your intent-filter in manifest file or not. If not, then enable it by adding android:autoVerify="true". This will enable link handling verification for your app. This should be added to every <intent-filter> in your manifest file which intended to handle an Android App Link.

Now, you have to prepare your activity to receive the intent data from the incoming link.

Sample code to handle intent:


protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  ...
  handleIntent(getIntent());
}

protected void onNewIntent(Intent intent) {
  super.onNewIntent(intent);
  handleIntent(intent);
}

private void handleIntent(Intent intent) {
    String appLinkAction = intent.getAction();
    Uri appLinkData = intent.getData();
    if (Intent.ACTION_VIEW.equals(appLinkAction) && appLinkData != null){
      // Do your action
    }
}

Associate app with website

To add Android App Links to your app, you must needs to verify that you own both your app and the website URLs. If the system successfully verifies that you own the URLs, the system automatically routes those URL intents to your app.

NOTE:

If the domain mentioned in the redirect url for your app in cidaas admin-ui is cidaas domain then app linking will work automatically. So, no need to follow the upcoming steps.

In case, if the redirect url in cidaas admin-ui is your own domain, then you must need to configure your domain to integrate app-links.


Steps to configure your website :

1. You must create a file called assetlinks.json in the following location.

https://[your_domain_name]/.well-known/assetlinks.json

2. To generate content for the assetlinks.json file, you can use google's digital-asset-links generator tool.

3. After filling domain name, package name and app package fingerprint, you generate json file by clicking on Generate statement button.

The generated assetlinks.json file will looks like the one below,

  [{
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "com.example",
      "sha256_cert_fingerprints": ["hash_of_app_certificate"] 
     }
   }]

4. Lastly, the assetlinks.json file must be hosted at https://[your_domain_name]/.well-known/assetlinks.json.

Testing

Now that your app and website are setup all you have left is to test it. Load an HTTPS link which is configured as described above. If your app is installed it should open the app, otherwise it should open the website.




results matching ""

    No results matching ""