TapTalk.io Documentation
  • Introduction
  • OneTalk Omnichannel Documentation
    • Getting Started with OneTalk
      • Team Members
      • Add Topic
      • Assign Agent to Topic
      • Paid Proactive Chat
    • Channel Integration
      • Telegram Integration
      • WhatsApp SME Integration
      • Instagram DM Integration
      • Facebook Messenger Integration
      • Live Chat Integration (iOS, Android, Web)
        • OneTalk Live Chat for Android
          • Get Started
          • Event Listener
          • Authentication
          • Case & Topic
          • Navigate Live Chat UI
          • Customize UI Appearance
        • OneTalk Live Chat for iOS
          • Get Started
          • Background Process in TapTalk.io Omnichannel iOS
          • Event Delegate
          • Authentication
          • Case & Topic
          • Navigate Live Chat UI
          • Customize UI Appearance
        • OneTalk Live Chat for Web
          • Get Started
          • Callback
          • Method
        • OneTalk Live Chat for React Native
          • Get Started - Android
          • Authentication - Android
          • Get Started - iOS
          • Authentication - iOS
        • OneTalk Live Chat for Flutter
          • Get Started - Android
          • Get Started - iOS
      • Google Business Messages Integration
      • Google Business Profile Integration
      • Tokopedia Integration
    • Integration API
      • Inbox API
      • User/Contact API
    • Live Chat Widget Callback Function
    • Social Channel Button
    • Custom Chatbot Integration
      • Get Started
      • Edit or Delete Chatbot
      • Development
    • QnA via API
    • Webhook
  • PowerTalk Chat SDK Documentation
    • Getting Started with PowerTalk
    • PowerTalk Android
      • Get Started
      • Enable Chat Features
      • Authentication
      • TapUI and TapCore
      • Background Process in TapTalk.io
      • Connection
      • Event Listener
      • Push Notification
      • General
      • User
      • Room List
        • Room List - TapUI
        • Room List - TapCore
      • Chat Room and Messages
        • Chat Room and Messages - TapUI
        • Chat Room and Messages - TapCore
      • Contact
      • Message Type
      • Customize UI Appearance
      • Customize Chat Features
      • Customize Chat Message Bubble
      • Customize Navigation Bar
      • Deep Linking
      • Error Codes
    • PowerTalk iOS
      • Get Started
      • TapUI and TapCore
      • Background Process in TapTalk.io
      • Implement Application Delegate
      • Authentication
      • Connection
      • Event Delegate
      • Push Notification
      • General
      • User
      • Room List
        • Room List - TapUI
        • Room List - TapCore
      • Chat Room and Messages
        • Chat Room and Messages - TapUI
        • Chat Room and Messages - TapCore
      • Contact
      • Message Type
      • Customize UI Appearance
      • Customize Chat Features
      • Customize Chat Message Bubble
      • Customize Navigation Bar
      • Deep Linking
      • Error Codes
    • PowerTalk React Native
      • Get Started - Android
      • Get Started - iOS
    • PowerTalk Flutter
      • Get Started - Android
      • Get Started - iOS
    • Javascript SDK
      • Get Started
      • Authentication
      • Connection
      • General
      • Event Listener
      • User
      • Room List
      • Chat Room
      • Messages
      • Contact
      • Message Type
    • Server API
      • Get Started
      • Base URL
      • Authentication
      • User
      • Contact
      • Message
      • Room
    • Webhook
      • Get Started
      • Webhook Payload
  • MeetTalk SDK Documentation
    • Getting Started with MeetTalk
    • MeetTalk Android
      • Get Started
      • Event Listener
    • MeetTalk iOS
      • Get Started
      • Implement Application Delegate
      • Event Delegate
  • SendTalk API Documentation
    • Introduction
    • Whatsapp Verification
Powered by GitBook
On this page
  • Step 1: Define a URL to open your app
  • Step 2: Specify an Activity to handle Deep Link
  • Step 3: Opening a Specific Activity from Deep Link
  • Step 4: Handling Deep Link for Android 12+

Was this helpful?

  1. PowerTalk Chat SDK Documentation
  2. PowerTalk Android

Deep Linking

PreviousCustomize Navigation BarNextError Codes

Last updated 1 month ago

Was this helpful?

You may set up a deep link for your preferred URL so that when users taps the defined URL from anywhere outside your app in their Android device, they will be redirected to your app for a smoother experience.

In this example, we will explain how to set up deep linking to open TapTalk.io's room list or a specific chat room page when user taps a specific link from their device.

Step 1: Define a URL to open your app

To start, choose a URL from your domain that will be used to open your app. In this example, we will try using .

You should use your own specified URL, the URL above is only meant as an example to make it easier to follow the guide.

Step 2: Specify an Activity to handle Deep Link

To be able to open your app from a URL, you will need to add an intent filter to your specified activity's tag inside the AndroidManifest.xml file. In this example, a new activity named TapDeepLinkActivity will be created specifically to handle deep links. You may also use an existing activity, such as your app's main activity, if you wish.

After you locate your chosen activity tag in the Manifest, add the following intent filter inside the <activity> tag. The previously defined URL as will be added as data for the intent filter.

AndroidManifest.xml
<application
    android:name=".YourApplication"
    ...
    
    <activity
        android:name="com.example.app.activity.TapDeepLinkActivity"
        android:exported="true"
        android:launchMode="singleTask">
        <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" />
            <data android:host="web.taptalk.io" />
            <data android:pathPrefix="/chat" />
        </intent-filter>
    </activity>

</application>

To create a link to your app content, add an intent filter that contains these elements and attribute values in your manifest:

Step 3: Opening a Specific Activity from Deep Link

The TapDeepLinkActivity from this example will act as a bridge to open TapTalk.io's room list page, or a specified chat room.

When the activity is launched from an intent filter, you can obtain the required data from the incoming Intent from the Activity.

TapDeepLinkActivity.java
package com.example.app.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import java.util.List;

import io.taptalk.TapTalk.Helper.TapTalk;
import io.taptalk.TapTalk.Listener.TapCommonListener;
import io.taptalk.TapTalk.Manager.TapUI;

public class TapDeepLinkActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        handleIntent();
        finish();
    }

    private void handleIntent() {
        Intent intent = getIntent();
        if (intent != null && intent.getData() != null) {
            Uri data = intent.getData();
            if (data.getHost().equals("web.taptalk.io")) {
                if (TapTalk.isAuthenticated()) {
                    List<String> pathSegments = data.getPathSegments();

                    if (pathSegments != null && !pathSegments.isEmpty()) {
                        // Get room ID from last path segment
                        String roomID = pathSegments.get(pathSegments.size() - 1);
                        openRoomList(roomID);
                    }
                    else {
                        // Fallback if room ID is not found
                        openRoomList("");
                    }
                }
                else {
                    // TapTalk not authenticated
                    // You may authenticate or open fallback activity
                    TapTalk.authenticateWithAuthTicket(AUTH_TICKET, true, new TapCommonListener() {
                        @Override
                        public void onSuccess(String successMessage) {
                            // Authentication success
                            handleIntent();
                        }

                        @Override
                        public void onError(String errorCode, String errorMessage) {
                            // Authentication success
                            openFallbackActivity();
                        }
                    });
                }
            }
            else {
                // Fallback if tapped url is not chat
                openFallbackActivity();
            }
        }
        else {
            // Fallback if data is null
            openFallbackActivity();
        }
    }

    private void openRoomList(String roomID) {
        // openRoomList with roomID parameter will open selected chat room after room list
        TapUI.getInstance().openRoomList(this, roomID);
    }

    private void openFallbackActivity() {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
    }
}
TapDeepLinkActivity.kt
package com.example.app.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.content.Intent
import io.taptalk.TapTalk.Helper.TapTalk
import io.taptalk.TapTalk.Listener.TapCommonListener
import io.taptalk.TapTalk.Manager.TapUI

class TapDeepLinkActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        
        handleIntent()
        finish()
    }

    private fun handleIntent() {
        if (intent != null && intent.data != null) {
            val data = intent.data
            if (data!!.host == "web.taptalk.io") {
                if (TapTalk.isAuthenticated()) {
                    val pathSegments = data.pathSegments
                    if (!pathSegments.isNullOrEmpty()) {
                        // Get room ID from last path segment
                        val roomID = pathSegments[pathSegments.size - 1]
                        openRoomList(roomID)
                    }
                    else {
                        // Fallback if room ID is not found
                        openRoomList("")
                    }
                }
                else {
                    // TapTalk not authenticated
                    // You may authenticate or open fallback activity
                    TapTalk.authenticateWithAuthTicket(
                        AUTH_TICKET,
                        true,
                        object : TapCommonListener() {
                            override fun onSuccess(successMessage: String) {
                                // Authentication success
                                handleIntent()
                            }

                            override fun onError(errorCode: String, errorMessage: String) {
                                // Authentication success
                                openFallbackActivity()
                            }
                        }
                    )
                }
            }
            else {
                // Fallback if tapped url is not chat
                openFallbackActivity()
            }
        }
        else {
            // Fallback if data is null
            openFallbackActivity()
        }
    }

    private fun openRoomList(roomID: String) {
        // openRoomList with roomID parameter will open selected chat room after room list
        TapUI.getInstance().openRoomList(this, roomID)
    }

    private fun openFallbackActivity() {
        val intent = Intent(this, MainActivity::class.java)
        startActivity(intent)
    }
}

You can also try using the above snippet for your own preferred Activity.

Step 4: Handling Deep Link for Android 12+

Starting in Android 12 (API level 31), a generic web intent resolves to an activity in your app only if your app is approved for the specific domain contained in that web intent. If your app isn't approved for the domain, the web intent resolves to the user's default browser app instead.

To handle this change, we will need to create an assetlinks.json file and place it under the .well-known/ directory of your host.

Creating the assetlinks.json file

You may create the file manually, create an empty file and name it assetlinks.json. The file should contain the following:

assetlinks.json
[
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "com.example.yourapppackagename",
      "sha256_cert_fingerprints":
      ["<Your App’s SHA256 fingerprint>"]
    }
  },
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "com.example.yourapppackagename.debug",
      "sha256_cert_fingerprints":
      ["<Your App’s SHA256 fingerprint>"]
    }
  }
]

The above example shows the contents of assetlinks.json file addressing your application for both debug and release build. Change the package_name and sha256_cert_fingerprints value respectively according to your application.

package_name can be obtained from the applicationId in your build.grade (:app) file.

One way to obtain SHA-256 fingerprint for your app is through running gradle signingReport from Android Studio.

Click on the gear icon on the top right of Android Studio, then select Run Anything, and type gradle signingReport, then press Enter. (menu location may vary according to version)

Android Studio will then execute a signingReport task. When it is finished, you can see all your app variants' fingerprints in the Debug tab at the bottom of the Android Studio window. Paste the SHA-256 value of your selected app variant to the assetlinks.json file.

Deploying the assetlinks.json file

  • The assetlinks.json file must be accessible without any redirects (no 301 or 302 redirects) and must be accessible by bots (your robots.txt must allow crawling /.well-known/assetlinks.json).

  • The assetlinks.json file must be served with content-type application/json.

  • The assetlinks.json file must be accessible over an HTTPS connection, regardless of whether the app's intent filters declare HTTPS as the data scheme.

Once all the steps above are successfully done, your app should be approved for your domain, and should be able to handle deep linking. You can try tapping the specified url from a test device to open your app.

From :

•

Specify the intent action so that the intent filter can be reached from Google Search.

•

Add one or more tags, each of which represents a URI format that resolves to the activity. At minimum, the tag must include the attribute.

You can add more attributes to further refine the type of URI that the activity accepts. For example, you might have multiple activities that accept similar URIs, but which differ simply based on the path name. In this case, use the attribute or its pathPattern or pathPrefix variants to differentiate which activity the system should open for different URI paths.

•

Include the category. It is required in order for the intent filter to be accessible from a web browser. Without it, clicking a link in a browser cannot resolve to your app.

Also include the category. This allows your app to respond to implicit intents. Without this, the activity can be started only if the intent specifies your app component name.

The example snippet below will show how to open a chat room from the specified roomID from the URL (i.e. ), or open the room list page when no roomID is specified

After generating the file, deploy it to the host under a .well_known directory. For this specific example, the file will be located at

to watch out for when hosting this file:

https://web.taptalk.io/chat
Android Developer
<action>
ACTION_VIEW
<data>
<data>
<data>
android:scheme
android:path
<category>
BROWSABLE
DEFAULT
https://web.taptalk.io/chat/roomID
https://web.taptalk.io/.well-known/assetlinks.json
Google provides some useful information