ASAPP provides the following notifications:

Push Notifications

ASAPP’s systems may trigger push notifications at certain times, such as when an agent sends a message to an end customer who does not currently have the chat interface open. In such scenarios, ASAPP calls your company’s API with data that identifies the recipient’s device, which triggers push notifications. ASAPP’s servers do not communicate with Firebase directly.

ASAPP provides methods in the SDK to register and deregister the customer’s device for push notifications.

For a deeper dive on how ASAPP and your company’s API handle push notifications, please see our documentation on Push Notifications and the Mobile SDKs.

In addition to this section, see Android’s documentation about Firebase Cloud Messaging and specifically how to setup Android Cloud Messaging.

Enable Push Notifications

  1. Identify which token you will use to send push notifications to the current user. This token is usually either the Firebase instance ID or an identifier generated by your company’s API for this purpose.

  2. Then, register the push notification token using:

    ASAPP.instance.updatePushNotificationsToken(newToken: String)
    

    In case you issue a new token to the current user, you also need to update it in the SDK.

Disable Push Notifications

In case the user logs out of the application or other related scenarios, you can disable push notifications for the current user by calling:

ASAPP.instance.disablePushNotifications().

Call this function before you change ASAPP.instance.user (or clear the session) to prevent the customer from receiving unintended push notifications.

Handle Push Notifications

You can verify if ASAPP triggered a push notification and passed a data payload into the SDK.

Your application usually won’t receive push notifications from ASAPP if the identified user for this device is connected to chat.

For a deeper dive on how Android handles push notifications, please see the Firebase docs on Receiving Messages in Android.

Background Push Notifications

If your app receives a push notification while in the background or closed, the system will display the OS notification. Once the user taps the notification, the app starts with Intent data from that push notification.

To help differentiate notifications from ASAPP and others your app might receive, ASAPP recommends that the push notification has a click_action with the value asapp.intent.action.OPEN_CHAT. For more information on how to set a click action, please see the Firebase documentation. With a click action set to the push notification, you will need to add a new intent filter to match it:

<activity android:name=".HomeActivity">
    <intent-filter>
        <action android:name="asapp.intent.action.OPEN_CHAT" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

Once you create the activity, check if it’s an ASAPP notification, and then open chat with the data:

if (ASAPP.instance.shouldOpenChat(intent)) {
    ASAPP.instance.openChat(context = this, androidIntentExtras = intent.extras)
}

The helper function shouldOpenChat simply checks if the intent action matches the recommended one, but its use is optional.

Foreground Push Notifications

When you receive Firebase push notifications while your app is in the foreground, it will call FirebaseMessagingService.onMessageReceived. Check if that notification is from ASAPP:

class MyFirebaseMessagingService : FirebaseMessagingService() {
    override fun onMessageReceived(message: RemoteMessage) {
        super.onMessageReceived(message)
        val wasFromAsapp = ASAPP.instance.onFirebaseMessageReceived(message)
        // ...
    }
}

For a good user experience, ASAPP recommends providing UI feedback to indicate there are new messages instead of opening chat right away. For example, update the unread message counter for your app’s chat badge. You can retrieve that information from: ASAPP.instance.conversationStatusHandler.

Persistent Notifications

The ASAPP Android SDK will automatically surface a persistent notification when a user joins a queue or is connected to a live agent (starting on v8.4.0). Tapping the notification triggers an intent that takes the user directly into ASAPP Chat. Once the live chat ends or the user leaves the queue, the notification is dismissed.

Persistent notifications are:

  • ongoing, not dismissible notifications.
  • low priority and do not vibrate or make sounds.
  • managed directly by the SDK and do not require integration changes.

ASAPP enables this feature by default. To disable it, please reach out to your ASAPP Implementation Manager.

Persistent notifications are not push notifications, which are created and handled by your application.

Customize Persistent Notifications

Notification Title and Icon

To customize the title of persistent notifications, override the following string resource:

<string name="asapp_persistent_notification_title">Chat for Customer Support</string>

And to customize the icon, create a new drawable resource with the following identifier (file name):

drawable/asapp_ic_contact_support.xml

ASAPP recommends that you do not change the body of persistent notifications.

Notification Channel

By default, ASAPP sets the notification to Notification Channel asapp_chat, but it is possible to customize the channel being used.

To customize the channel used by persistent notifications, override the following string resources:

<string name="asapp_persistent_notification_channel_id">asapp_chat</string>
<string name="asapp_persistent_notification_channel_name">Chat for Customer Support</string>