Push Notifications with the Service Chat SDK for Android
To take advantage of push notifications from your org to your app, set up an Apex trigger and configure your app for notifications. Pass relevant notification information, such as case feed activity, to the Service Chat SDK using your PushNotificationListener implementation.
The legacy chat product is scheduled for retirement on February 14, 2026, and is in maintenance mode until then. During this phase, you can continue to use chat, but we no longer recommend that you implement new chat channels. To avoid service interruptions to your customers, migrate to Messaging for In-App and Web before that date. Messaging offers many of the chat features that you love plus asynchronous conversations that can be picked back up at any time. Learn about chat retirement in Help.
The following activities can cause notifications:
- Agent has connected
- Agent sent a message
- Agent requested a file transfer
- Agent canceled a file transfer
- Agent ended a session
To implement notifications, follow these steps:
-
Set up authentication in your app. To learn more, see Authentication with the Service Chat SDK for Android.
-
Add FCM (Firebase Cloud Messaging) to your app. To learn more, see Google’s documentation, Add Firebase to Your Android Project.
Avoid any references to GCM (Google Cloud Messaging) in your build dependencies and your
AndroidManifest.xmlfiles. If you experience aNoClassDefErrorwhich claims thatGcmReceiveris missing, it may be included in your final merged manifest by one of your dependencies, such as the Salesforce Mobile SDK. To resolve the error, add the following remove instruction to yourAndroidManifest.xml:<receiver android:name="com.google.android.gms.gcm.GcmReceiver" tools:node="remove"/>. -
Add a
connected-appdependency in your module’sbuild.gradlefile.Service Chat SDK
The version of the connected-app is the same as the version of the Common module used by the Service Chat SDK.
-
Create a connected app and an Apex trigger to send a notification from your org. Follow the instructions in the Salesforce Mobile Push Notifications Implementation Guide for Creating a Connected App.
-
Implement
PushNotificationListenerand handle the push notification event in theonPushNotificationReceivedmethod. -
Configure using the Sender ID,
AuthTokenProvider, and the site URL.Pass this object your push notification listener and then register your device for push notifications.
In Java:
In Kotlin: