Overview
Confused about "Overview"?
Let us know how we can improve our documentation:
Stream Chat supports push notifications through Firebase Cloud Messaging, Apple Push Notification (APN), Huawei Push and Xiaomi Push.
Push notifications are only sent for new messages and not for other events. You can use Webhooks to send push notifications on other types of events.
Setting up Push
Copied!Confused about "Setting up Push"?
Let us know how we can improve our documentation:
Push is available to Stream Chat integrations running in a mobile environment.
Depending on which Stream Chat SDK you are using, the process for setting up push notifications will be slightly different. Follow the guide for your chosen SDK:
Push Delivery Rules
Copied!Confused about "Push Delivery Rules"?
Let us know how we can improve our documentation:
Push message delivery behaves according to these rules:
- Push notifications are sent only for new messages.
- Only channel members receive push messages.
- Members receive push notifications regardless of their online status.
- Replies inside a thread are only sent to users that are part of that thread:
- They posted at least one message
- They were mentioned
- Messages from muted users are not sent.
- Messages are sent to all registered devices for a user (up to 25) .
- Up to 100 members of a channel will receive push notifications for push v1.
- Up to 1000 members of a channel will receive push notifications for push v2. This limit can be increased per app through customer support.
skip_push
is marked asfalse
, as described here.push_notifications
is enabled (default) on the channel type for message is sent.
Handling Push Notifications on the Foreground
Copied!Confused about "Handling Push Notifications on the Foreground "?
Let us know how we can improve our documentation:
Both iOS and Android discard push notifications when your application is on the foreground.
You can configure this on your application and decide what to do when a push notification is received while the app is on the foreground.
Push Notification Payload
Copied!Confused about "Push Notification Payload"?
Let us know how we can improve our documentation:
Push notifications are delivered as data payloads that the SDK can use to convert into the same data types that are received when working with the APIs.
When a message received by the Chat API, according to the delivery rules, it kicks a job that sends a regular data message (as below) to configured push providers on your app. According to the battery and the online status of the device, push providers deliver this payload to the actual devices. When a device receives the payload, it's passed to the SDK which connects to Chat API to receive regular message and channel records and unmarshals them into in-memory objects and gives control to you by passing these objects. At this point, your application can use these objects to generate any push notification to be shown to the user.
This is the main payload which will be sent to each configured provider:
On both Android and iOS the SDK will convert the payload in channel and message types and allow you to customize the notification message.
You can find more details, examples and guides on specific use-cases on the specific SDK docs.
Push Notification Configuration
Copied!Confused about "Push Notification Configuration"?
Let us know how we can improve our documentation:
Firebase
Copied!Confused about "Firebase"?
Let us know how we can improve our documentation:
v2: Requires a service worker account from your FCM project.
Firebase console → project settings (top left) → service accounts (4th sub header) → generate a new private key
Export your key and upload in the firebase credentials field in dashboard. A sample content:
v1: Requires a server key
Firebase console → project settings (top left) → cloud messaging (2th sub header) → add server key
It will generate a long key and save in the firebase server key field in dashboard. A sample key:
AAAAktWCgMU:APA91bGIcyTcdvT0DQqDIfdFPyc5Bk8hH-z5EfFcWI7WFiXOFDKhcspm-Uy_znvEvXfaOOZrFMIP1XAK8drZr7vM70UihXtyz7ZsL3KiSkgkrXk7BJgZZ_VybPLc6ug9baXIAw1zz2nk
Troubleshooting
Copied!Confused about "Troubleshooting"?
Let us know how we can improve our documentation:
Push notifications are not always intuitive to implement because they involve systems outside of Stream Chat with a number of moving parts. We've put together some resources on common errors and how to resolve them.
Other Push Providers
Copied!Confused about "Other Push Providers"?
Let us know how we can improve our documentation:
While Stream Chat doesn't have first class integration for Push providers besides Firebase, APN, Huawei and Xiaomi, it is entirely possible to integrate with additional providers using Webhooks.