Notifications for Chat Activity
If there’s chat activity when the user is not viewing the chat session, you can present that information to them using the iOS notification system.
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.
Notifications can be sent to the user when the user isn’t viewing the chat session. A notification can appear when the app is in the background, or when the app is in the foreground but the chat session is minimized. 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
- Session will timeout soon
To ensure that the app can send these notifications while in the background, chat must be configured to allow background execution (allowBackgroundExecution) and to allow for background notifications (allowBackgroundNotifications). Both these settings are turned on by default. See Configure a Chat Session for details.
-
Import the
UserNotificationsframework in yourAppDelegateclass.In Swift:
In Objective-C:
-
Register for local notifications in your
AppDelegate’sdidFinishLaunchingWithOptionsmethod.In Swift:
In Objective-C:
-
Implement
UNUserNotificationCenterDelegate. Handle thedidReceiveNotificationResponseandwillPresentNotificationmethods.iOS calls the
didReceiveNotificationResponsemethod when your app is in the background. In this method, you can tell your app to enter the foreground and for chat to maximize. To perform this behavior, use thehandle(notification:)method on theSCSChatInterfaceobject, which is accessible from thechatUIproperty of theServiceCloudshared instance.iOS calls the
willPresentNotificationmethod when your app is in the foreground. To determine whether to display the notification, use theshouldDisplayNotificationInForegroundmethod (accessible from thechatUIproperty of theServiceCloudshared instance). If the Chat UI is already showing the relevant information related to this event, the method returnsfalse.In Swift:
In Objective-C: