15-day Pro trial · no credit cardStart free →

Mobile SDKs

Push notifications

Push notifications (FCM and APNs) for the STINGIM mobile SDKs from 1.0.0-rc.4: console credentials, Android and iOS setup, troubleshooting.

Push notifications are supported from SDK 1.0.0-rc.4 on Android and iOS. When an agent or the AI agent replies while your app is in the background or closed, STINGIM sends a system notification to the visitor's phone; tapping it opens the conversation.

To make it work you need two things: your app passes its device token to the SDK, and you configure FCM / APNs credentials in the console. Without credentials, tokens are still registered but no notification is sent.

How it works

AndroidiOS
Push serviceFirebase Cloud Messaging (FCM)APNs (token-based .p8 key), or FCM if your app already uses Firebase
Register the tokenStingimPush.setPushToken(context, fcmToken)Stingim.shared.registerPushToken(deviceToken) or registerFCMToken(fcmToken)
Show / open notificationsStingimPush.handleRemoteMessage, StingimPush.handleOpenIntentStingimPush.presentationOptions(for:), StingimPush.handle(response:), StingimPushUI
Console credentialFCM service account JSONAPNs .p8 key (Key ID, Team ID, Bundle ID) or FCM service account JSON
  • The SDK stores the token and uploads it for the current visitor. It is uploaded again after login, identity switch and token recovery; the call is idempotent.
  • disconnect() removes this device's registration before the visitor token is cleared.
  • No push is sent while the visitor is connected (the message arrives in real time); the delivery log shows these as Skipped. While a token is registered, the SDK closes its connection shortly after the app goes to the background and resyncs missed messages when it returns.
  • Notifications are suppressed while the chat screen is visible.

1. Configure credentials in the console

  1. Open Settings → Channels → App SDK and click Push notifications on your app.
  2. Upload a credential: - FCM (required for Android): in the Firebase console open Project settings → Service accounts → Generate new private key and upload the JSON file. Do not use google-services.json. - APNs (iOS): in Apple Developer open Certificates, IDs & Profiles → Keys → +, enable Apple Push Notifications service (APNs) and download the .p8 key. Upload it with the Key ID, Team ID and your app's Bundle ID, and choose Sandbox (builds run from Xcode) or Production (TestFlight / App Store).
  3. Turn on Send push notifications. Optionally turn off Show message preview — the notification then only says "You have a new message".
  4. Use Test send with a device token from your app's logs to check the credential, and the Delivery log to see recent results.

Keys are stored encrypted and never shown again; the console only shows a fingerprint.

2. Android (FCM)

The SDK has no Firebase dependency: add firebase-messaging and google-services.json to your app, then forward tokens and messages to StingimPush.

Java
public class MyMessagingService extends FirebaseMessagingService {
    @Override
    public void onNewToken(@NonNull String token) {
        StingimPush.setPushToken(this, token);
    }

    @Override
    public void onMessageReceived(@NonNull RemoteMessage message) {
        RemoteMessage.Notification n = message.getNotification();
        if (StingimPush.handleRemoteMessage(this, message.getData(),
                n != null ? n.getTitle() : null, n != null ? n.getBody() : null)) {
            return; // STINGIM push handled
        }
        // your own pushes
    }
}

In your launcher activity call StingimPush.handleOpenIntent(this, getIntent()) in onCreate (when savedInstanceState == null) and StingimPush.handleOpenIntent(this, intent) in onNewIntent — a tapped notification opens the chat. On Android 13+ request the POST_NOTIFICATIONS permission. Call StingimPush.clearPushToken(context) when the user turns notifications off in your app.

3. iOS (APNs)

Enable the Push Notifications capability in Xcode, request permission and pass the device token to the SDK:

Swift
func application(_ application: UIApplication,
                 didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    Stingim.shared.registerPushToken(deviceToken)
}

func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification,
                            withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
    if StingimPush.isStingimNotification(notification.request.content.userInfo) {
        completionHandler(StingimPush.presentationOptions(for: notification))
    } else {
        completionHandler([.banner, .list, .sound])
    }
}

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse,
                            withCompletionHandler completionHandler: @escaping () -> Void) {
    _ = StingimPush.handle(response: response)
    completionHandler()
}

registerPushToken may be called before Stingim.shared.start(...). With the built-in UI, StingimPushUI.installDefaultOpenHandler(title:) opens the chat screen from a notification. The SDK reports the APNs environment automatically (sandbox for DEBUG builds, otherwise production); override it with StingimConfig.apnsEnvironment. Apps that already use Firebase can call Stingim.shared.registerFCMToken(fcmToken) instead and upload an FCM credential. unregisterPushToken() turns push off for the device.

Troubleshooting

  • Nothing arrives: check that the app's push status in the console is Active (credential uploaded and Send push notifications on), and that a test send to the same token succeeds.
  • BadDeviceToken (APNs): the environment does not match the build — use Sandbox for Xcode builds, Production for TestFlight / App Store.
  • DeviceTokenNotForTopic (APNs): the Bundle ID in the console does not match the app.
  • Skipped in the delivery log is normal: the visitor was connected and received the message in the app.

See the changelog for the full list of push APIs.

Found a mistake? Email [email protected]