8000 GitHub - contacto-io/contacto-examples-android: Sample android code and apps which use Contacto SDKs
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

contacto-io/contacto-examples-android

Repository files navigation

Contacto Android SDK and Examples

Table of Contents

Features

Getting Started

Requirements

Contacto SDK clients require devices running Android 10 or higher.

Setup

Get your App ID and App Key

Sign in to your Contacto account as an Administrator. Navigate to Channels > Chat, select the Chat App to be integrated, and navigate the Code tab to access the APP ID and App Key.

auth-credentials-from-contacto-console

Add ContactoSDK to your project

Add the Contacto SDK dependency to the root build.gradle (project/build.gradle)

Gradle Kotlin DSL
implementation("com.contacto:contacto-android:1.0.3")
Gradle Groovy DSL
implementation 'com.contacto:contacto-android:1.0.3'

Code snippets to add Contacto SDK using other dependency managers are available here.

Usage

Initialize the Contacto SDK

Invoke ContactoClient.init() with your APP ID and APP KEY before invoking/ using any feature of Contacto SDK.

Kotlin
import com.contacto.consumer.android.ContactoClient
import com.contacto.consumer.android.ui.model.User

appId = "{{APP ID of the Chat App}}", // Access the APP ID from the Contacto Console (https://console.contacto.com)
appKey = "{{APP Key of the Chat App}}" // Access the APP Key from the Contacto Console (https://console.contacto.com)

ContactoClient.init(appId = appId, appKey = appKey)
Java
import com.contacto.consumer.android.ContactoClient
import com.contacto.consumer.android.ui.model.User

appId = "{{APP ID of the Chat App}}", // Access the APP ID from the Contacto Console (https://console.contacto.com)
appKey = "{{APP Key of the Chat App}}" // Access the APP Key from the Contacto Console (https://console.contacto.com)

ContactoClient.INSTANCE.init(appId, appKey);

User Information

You can send basic user information at any point to give you more context on the user when your support agents are messaging back and forth with them.

Kotlin
val user = User(
   firstName = {{User's first name}},
   lastName = {{User's last name}},
   phoneNumber = "{{User's phone number}}",
   email = "{{User's email address}}"
)
Java
User user = new User(
   {{User's first name}},
   {{User's last name}},
  "{{User's phone number}}", 
  "{{User's email address}}"
);

Initiate a Chat Conversation

Kotlin
ContactoClient.loadChat(this, user)
Java
ContactoClient.INSTANCE.loadChat(this, user);

Handle Errors on Initiating a Conversation

Kotlin
import com.contacto.consumer.android.utility.Constants

@Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode == Constants.ERROR_CODE) {
            String error = data.getStringExtra(Constants.PARAM_ERROR);
            Snackbar.make(binding.root, error, Snackbar.LENGTH_SHORT).show();
        }
    }

Examples

The repository contains sample apps to familiarize you with the Contacto Android SDK. You can re-use the code available here in your own Apps. Each example in this project is a stand-alone Android app, capable of being run independently through Gradle or Android Studio.

The current list of samples apps are:

Contributions

We welcome contributions of any kind including new examples, bug fixes, and documentation improvements. We recommend opening an issue describing what you want to build so that we can discuss how to move forward if it is a major change. For minor changes such as typo fixes and one-liners, go ahead and open a pull request.

Bugs

Please submit bug reports to Contacto.

About

Sample android code and apps which use Contacto SDKs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  
0