In-App Chat

This page covers the APIs specific to in-app chats for Android apps.

Push Notifications

You can set Instabug to send your app a push notification each time a new chat message is received.

Push Notifications Key

Follow the steps below to upload your push certificate to your Instabug dashboard.

  1. Go to the Push Notifications page on your Instabug dashboard and add you API_KEY.
  2. Make sure to select whether the API_KEY you're adding is for development or production.

Setting Your App to Handle Instabug Notifications

Pass the push notifications' registration token you get to Instabug.

Instabug.setPushNotificationRegistrationToken("PUSH_NOTIFICATION_TOKEN");

When you receive a notification, check if it's an Instabug notification, then pass it to Instabug if necessary.

if(Instabug.isInstabugNotification(data)){
  //Shown notification related to Instabug
  Instabug.showNotification(data);
}

Disabling Push Notifications

Push notifications are enabled by default if you upload a push certificate to you Instabug dashboard. To disable them, modify your builder method as in the following example.

new Instabug.Builder(this, "APP_TOKEN")
  	.setPushNotificationState(DISABLED)
  	.build():

In-app Notifications

By default, a notification will be shown on top of your app's UI when a new message is received.

Disabling In-App Notifications

Use the following method to disable notifications that appear in-app.

Instabug.setReplyNotificationEnabled(false);

In-App Notifications' Sound

In-App notifications' sound is enabled by default. However, you can disable it by adding the following method to Instabug builder:

Instabug.setInAppReplyNotificationSound();

System Notifications' Sound

System notifications' sound is also disabled by default. You can enable it by adding the following method to Instabug builder:

Instabug.setEnableInAppNotificationSound();

Conversations' Sound

New messages' sound in conversation is also enabled by default. You can disable it by adding the following method to Instabug builder:

Instabug.setShouldPlayConversationSounds(false);

Get Unread Messages Count

You can use the following method to get the amount of messages the user has yet to read.

Instabug.getUnreadMessagesCount();

SDK Events

New Received Message

This block is executed each time a new message is received. This can be used to show your own UI when a new message is received.

Instabug.setOnNewReplyRecievedCallback(new Runnable() {
  @Override
  public void run() {
    //Show an alert to notify users about a new message.
  }
});

Enabling and Disabling

Bug reporting, feedback, and chats can be enabled or disabled separately. When the user invokes the SDK with any of the invocation events, a popup appears showing all the enabled features. When only a single option is enabled, it becomes the default invocation mode and the popup doesn't appear. If all options are disabled, bug reporting becomes the default invocation mode.

BugReporting.setPromptOptionsEnabled(PromptOption.BUG, PromptOption.FEEDBACK);

By default, all three options for In-App Chats are enabled if they are available in your current plan.