Add the HelpCrunch Android SDK to your app

You can add the HelpCrunch SDK to your Android application with either Gradle or Maven build systems, and here's how.
Written by Alex
Updated 6 months ago

You can add the HelpCrunch SDK to your Android application with the Gradle build system.

1. Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

2. Add the following code to your app/build.gradle file:

implementation 'com.helpcrunch:chat-sdk:x.x.x'

The current version of the SDK can always be found on the demo page or the Maven Central Repository Search 

3. For the next step, you'll need the Android Initialization Code. You can copy this code from the apps list in your HelpCrunch account (Settings→ Set up & Customize → Android APPs → Your app name → Android Initialization Code).

Setup code

1. Initialize Helpcrunch in your custom application class with your Android Initialization Code:

Java

HelpCrunch.initialize(YOUR_HELPCRUNCH_SUBDOMAIN, YOUR_APP_ID, YOUR_APP_SECRET);

Kotlin

HelpCrunch.initialize(HELPCRUNCH, HELPCRUNCH_APP_ID, HELPCRUNCH_SECRET)

HelpCrunch.initialize(YOUR_HELPCRUNCH_SUBDOMAIN, YOUR_APP_ID, YOUR_APP_SECRET)

2. After SDK initialization, call the showChatScreen helper method in HelpCrunch in order to show a chat screen to your app users:

Java

HelpCrunch.showChatScreen();
//or
HCOptions options = HCOptions.createDefault(); //default or custom

HelpCrunch.showChatScreen(options, new Callback<Object>(){
    @Override
    public void onSuccess(Object result) {
    }
    @Override
    public void onError(@NotNull String message) {
    }
});

Kotlin

HelpCrunch.showChatScreen()
//or
val options = HCOptions.createDefault() //default or custom

HelpCrunch.showChatScreen(
		options = options,
		callback = object : Callback<Any?>() {
			override fun onSuccess(result: Any?) {
			}
			override fun onError(message: String) {
			}
		}
)

3. After you have called the method, the HelpCrunch chat widget will look like this in your app:

If your application also uses Firebase to manage notifications, then take a look at this article: Enable push notifications for Android. FirebaseMessagingService conflicts

Did this answer your question?