androidchatsdk

Gladly Android Chat SDK

Welcome to Gladly’s Android Chat SDK.

If you’re not sure where to start, it’s best to begin looking at the Gladly instance object. There you will find most of the functionality needed to configure, initialize, and start the Glad App/Chat Activity.

Example

An example application on how to use this SDK can be found here.

Requirements

The Gladly Android Chat SDK is compatible with devices running Q (API 29) and above.

Getting Started

Here’s how to integrate Gladly’s Android Chat SDK

In your main application’s onCreate(..), setup Gladly and pass in parameters to configure the chat look and feel to your liking.

class MainApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        
        val eventInterface = object : EventInterface {
            override fun onEvent(event: GladAppEvent) {
                Log.d(TAG, "EventInterface: onEvent: $event")
            }
        
            override fun onError(error: GladAppError) {
                Log.e(TAG, "EventInterface: onError: $error")
            }
        
            override fun onMessageReceived(text: String) {
                Log.i(TAG, "EventInterface: onMessageReceived: $text")
            }
        }
        try {
            Gladly.initialize(context, settings, eventInterface)
            Gladly.set(context, user)
        } catch (e: Exception) {
            Toast.makeText(context, "could not set user!", Toast.LENGTH_LONG).show()
        }
}

Then when your app is ready to display the chat, use Gladly.showChat to start.

try {
    Gladly.showChat(context)
} catch (e: Exception) {
    Toast.makeText(context, "could not set user!", Toast.LENGTH_LONG).show()
}

And this is how you would roughly handle the Firebase messages in your Firebase Service.

override fun onMessageReceived(remoteMessage: RemoteMessage) {
    super.onMessageReceived(remoteMessage)

    if (Gladly.handleMessageReceived(this, remoteMessage, MainActivity.shown)) {
        Log.i(TAG, "Gladly SDK handled this message...")

        // TODO: This is where you would update your store of unread counts or update your UI. This is just an example
        // of broadcasting this to the specified Activity to update it's view.
        Intent().let { intent ->
            intent.putExtra(BROADCAST_UPDATE_UNREAD_COUNT_EXTRA, Gladly.getUnreadCount(this))
            intent.action = BROADCAST_UPDATE_UNREAD_COUNT
            LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
        }

        return
    }

    // TODO: This is where you would handle your other push notifications.
    Log.i(TAG, "Got a non-gladly SDK message. ")
}

Packages

Name Summary
Glad App Android SDK
Notable Classes

Index

All Types