Skip to main content

Push notifications

Push notifications tell visitors about new activity while your app is in the background or closed. Zoho SalesIQ sends them through Firebase Cloud Messaging (FCM), using the HTTP v1 API.

At Zylker Bakes, for example, visitors often ask about an order and then close the app. When an operator replies, the reply appears on the visitor's phone as a notification, and tapping it opens the chat.

Visitors receive notifications for the following events:

  • New chat messages from operators or bots.
  • Incoming voice calls, as well as missed and canceled calls.
  • Chats that have ended.
  • Messages that your team sends to previous visitors from the visitor history in SalesIQ. For example, an operator can start a new chat with a visitor, or send a campaign, such as a broadcast message. To learn how to send a broadcast, see Sending broadcast messages.
  • Outbound messages that you send to many visitors at once, based on criteria you define in the SalesIQ console.

One setup covers all of these notifications. Your messaging service passes each SalesIQ notification to the SDK, and the SDK shows it and opens the right screen when the visitor taps it.

To handle each event type yourself instead, parse the payload into a SalesIQNotificationPayload object. Then check whether it is a Chat, Call, VisitorHistory, or EndChatDetails subtype.

How delivery works

The following diagram shows how a notification travels from SalesIQ to your app.

SalesIQ serverSends a new chat messageFirebase Cloud MessagingDelivers it with the HTTP v1 APIFirebaseMessagingServiceonMessageReceived(data)SalesIQ notification?isZohoSalesIQNotification(data)YesNotification.handle(context, data)The SDK shows the notificationNoYour app handles itThe visitor taps, and the chat opensOpened by the SDK or your app, based on ActionSource
Your FirebaseMessagingService receives every notification. Use isZohoSalesIQNotification() to pass SalesIQ messages to the SDK. The ActionSource setting (SDK or APP) decides who opens the chat when the visitor taps the notification.

Setup overview

The setup has six steps. Step 1 and step 3 take place in the SalesIQ and Firebase consoles. The other steps are in your app project.

  1. Enable push notifications for your brand in the SalesIQ console.
  2. Add Firebase to your Android app.
  3. Upload your FCM HTTP v1 private key to SalesIQ.
  4. Add the notification permission.
  5. Register your messaging service.
  6. Pass incoming messages to the SDK and register the device token.

Step 1: Enable push notifications in the SalesIQ console

In the SalesIQ console, open Settings, select Brands, choose your brand, go to Installation, then Mobile SDK, and select Android. Then turn on Configure push notifications. You will upload your FCM private key on this same screen in step 3.

The Android installation screen in the SalesIQ console, with the Configure push notifications option

Step 2: Add Firebase to your app

If your app does not use Firebase yet, follow these steps:

  1. Create a Firebase project, or open an existing one.
  2. Add your Android app to the Firebase project.
  3. Download the google-services.json file and add it to your app module folder.
  4. Add the Google Services Gradle plugin to your project.

For details, see the Firebase guide Add Firebase to your Android project.

Step 3: Upload the FCM HTTP v1 private key

SalesIQ needs a private key from your Firebase service account to send notifications on your behalf. The key is a JSON file, so store it securely. To generate the key and upload it to SalesIQ:

  1. Open the Firebase console and select your project.

  2. Click the gear icon, select Project settings, and go to the Service accounts tab.

    The gear icon menu in the Firebase console, with the Project settings option
  3. Under Firebase Admin SDK, click Generate new private key.

    The Service accounts tab in the Firebase console, with the Generate new private key button
  4. Click Generate key to confirm. The key downloads to your computer as a JSON file.

    The Generate new private key confirmation dialog in the Firebase console
  5. Go back to Configure push notifications in the SalesIQ console, and click Browse.

  6. Select the JSON file that you downloaded, and click Upload.

tip

Make sure the Firebase Cloud Messaging API (V1) is enabled for your project. To check, open the Cloud Messaging tab in your Firebase project settings. If the API is disabled, click the three-dot menu next to Firebase Cloud Messaging API (V1), and select Manage API in Google Cloud Console. Then click Enable.

The Firebase Cloud Messaging API page in the Google Cloud console, with the Enable button

Step 4: Add the notification permission

On Android 13 (API level 33) and above, your app must declare the POST_NOTIFICATIONS permission and ask the visitor for it while the app runs. If the visitor does not allow it, replies still arrive in the chat, but the device does not show a notification.

Add the permission to your AndroidManifest.xml file:

AndroidManifest.xml
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

To learn how to request the permission at runtime, see the Android guide on notification runtime permission.

Step 5: Register your messaging service

SalesIQ notifications arrive through a standard FirebaseMessagingService, which is the class that Firebase starts when a message reaches the device. If you are new to FCM, first follow the Firebase guide Set up an FCM client app on Android.

Declare your messaging service in your AndroidManifest.xml file:

AndroidManifest.xml
<service
android:name=".MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

Step 6: Pass messages to the SDK

Your app may send its own notifications too. Zylker Bakes, for example, sends order updates. So the messaging service checks each message before it passes it on. Add the following code to your messaging service:

  • In onMessageReceived(), check whether the message is from SalesIQ, and pass SalesIQ messages to the SDK.
  • In onNewToken(), register the new token with SalesIQ.
MyFirebaseMessagingService.kt
class MyFirebaseMessagingService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
val data = remoteMessage.data
if (ZohoSalesIQ.Notification.isZohoSalesIQNotification(data)) {
ZohoSalesIQ.Notification.handle(applicationContext, data)
} else {
// Handle your app's own notifications.
}
}

override fun onNewToken(token: String) {
ZohoSalesIQ.Notification.enablePush(token, isTestDevice = false)
}
}

Register the device

SalesIQ can send notifications to a device only after you register the device's FCM token. Call enablePush() after the SDK is initialized, and again from onNewToken() whenever Firebase issues a new token.

ZohoSalesIQ.Notification.enablePush(fcmToken, isTestDevice = false)
ParameterTypeDescription
tokenStringThe FCM registration token for the device.
isTestDeviceBooleanSet to true to receive test messages from the SalesIQ console, or false for production.

Unregister the device

To stop notifications on a device, for example when the visitor logs out, call disablePush(). It uses the FCM token that you registered with enablePush(), so it takes no parameters.

ZohoSalesIQ.Notification.disablePush()

Identify SalesIQ notifications

When your app receives its own notifications as well, check whether a payload is from SalesIQ before you handle it:

val isSalesIQ = ZohoSalesIQ.Notification.isZohoSalesIQNotification(data)

Handle the notification tap

By default, the SDK opens the chat when the visitor taps a SalesIQ notification. To handle the tap in your app instead, change the action source:

// The SDK opens the relevant chat. This is the default.
ZohoSalesIQ.Notification.setActionSource(ZohoSalesIQ.ActionSource.SDK)

// Your app receives the payload and handles the navigation.
ZohoSalesIQ.Notification.setActionSource(ZohoSalesIQ.ActionSource.APP)
SourceDescription
SDKThe SDK opens the relevant chat when the visitor taps the notification. This is the default.
APPYour app receives the payload through NotificationListener.onClick() and handles the navigation.

Customize the notification

Small icon

The small icon of the notification is a style attribute, so it follows your app's theme. To use your own icon, override siq_notification_small_icon in your SalesIQ theme. Its background color is set by siq_notification_small_icon_background_color.

res/values/styles.xml
<item name="siq_notification_small_icon">@drawable/ic_notification</item>
<item name="siq_notification_small_icon_background_color">@color/your_accent</item>

To learn how to override the SalesIQ theme, see the Customize the colors section. The Styles section lists every attribute that you can change.

Channel name

By default, the SDK posts notifications to a channel named "Support Notifications". Visitors see this name in the notification settings of your app. To change it, override the following string resource:

res/values/strings.xml
<string name="siq_mobilisten_notification_channel_name">Messages from support</string>

Test your setup

To check your setup, send a test notification from the SalesIQ console:

  1. Register the device with isTestDevice set to true.
  2. In the SalesIQ console, open the push notification test option on the Android installation screen.
  3. Enter your message and click Send. All registered test devices receive the message.
note

When you delete a test device, it stops receiving test messages only. Production notifications still arrive.