// Comment with direct push notification (default behavior)
await client.addComment({
object_id: activity.id,
object_type: "activity",
comment: "Great post!",
// skip_push: false (default) - sends push immediately
});
// Reaction with direct push notification
await client.addReaction({
activity_id: activity.id,
type: "like",
// skip_push: false (default) - sends push immediately
});
Overview
Stream Activity Feeds supports push notifications through Firebase Cloud Messaging (FCM) and Apple Push Notification (APN) providers.
Push notifications help keep users engaged by delivering real-time updates about activities, reactions, comments, and other feed events when the application is closed or in the background.
The Stream API doesn’t support web push notifications. However, if you’re building a mobile application using JavaScript technologies, you can set up mobile push notifications using the supported providers: Firebase Cloud Messaging (FCM) and Apple Push Notification (APN).
When Push Notifications Are Sent
Activity Feeds sends push notifications in the following scenarios:
- New Follower when a user follows another user
- Comments added to activities the user is involved with
- Reactions added to the user’s activities
- Comment Reactions added to the user’s comments
- Mentions when a user is mentioned in activities or comments
- Notification feeds - activities added to the default notification feed automatically trigger push notifications
Push Delivery Rules
Push notification delivery follows these rules for Activity Feeds:
- Only users with registered devices receive push notifications
- Push notifications are sent to all registered devices for a user (up to 25 devices)
- Users must have proper permissions granted for notifications
- Push notifications are sent for activity updates like new comments and reactions
- Notifications respect the feed’s privacy settings and user permissions
- Activities added to the default notification feed automatically trigger push notifications
- You can skip push notifications for individual actions using the
skip_push
parameter on comments, reactions, and follows
Feed Groups and Push Notifications
Push notifications in Activity Feeds are configured at the feed group level. Each feed group can have its own push notification settings:
- Built-in feed groups like
notification
anduser
come with default push configurations - Custom feed groups can be created with specific push notification settings
- Activity types can be selectively enabled for push notifications using
push_types
For detailed configuration options, refer to the Feed Group Push Configuration documentation.
Configuring Push Providers
You need to configure your push providers through the Stream Dashboard:
- Navigate to your Stream Dashboard
- Select your application
- Go to the Push Notifications section
- Click New Configuration and select your provider
- Upload your credentials (Firebase service account JSON, APN certificates, etc.)
For detailed configuration instructions, refer to the Push Providers & Multi Bundle documentation.
Getting Started
To set up push notifications for Activity Feeds, you need to:
- Configure your push notification provider on the Stream Dashboard
- Add client-side integration for your chosen provider in your app
- Register user devices with Stream’s API
Implementation Examples
Direct Push Notifications
Direct push notifications are sent immediately when events occur. Use skip_push: false
(default) to enable direct push:
// Comment with direct push notification (default behavior)
await serverClient.feeds.addComment({
object_id: activity.id,
object_type: "activity",
comment: "Great post!",
user_id: "user-456",
// skip_push: false (default) - sends push immediately
});
// Reaction with direct push notification
await serverClient.feeds.addReaction({
activity_id: activity.id,
type: "like",
user_id: "user-456",
// skip_push: false (default) - sends push immediately
});
Notification Feed Push Notifications
Use create_notification_activity: true
with skip_push: true
to send push via the built-in notification feeds
:
// Comment that creates notification activity and sends via notification feed
await client.addComment({
object_id: activity.id,
object_type: "activity",
comment: "Great post!",
create_notification_activity: true,
skip_push: true, // Send via notification feed instead of direct push
});
// Reaction that creates notification activity
await client.addReaction({
activity_id: activity.id,
type: "like",
create_notification_activity: true,
skip_push: true, // Send via notification feed
});
// Comment that creates notification activity and sends via notification feed
await serverClient.feeds.addComment({
object_id: activity.id,
object_type: 'activity',
comment: 'Great post!',
user_id: "user-456",
create_notification_activity: true,
skip_push: true // Send via notification feed instead of direct push
});
// Reaction that creates notification activity
await serverClient.feeds.addActivityReaction({
activity_id: activity.id,
type: 'like',
user_id: 'user-456'
create_notification_activity: true,
skip_push: true, // Send via notification feed
});
Custom Notification Feeds
Manually add activities to custom notification feeds for complete control (only for server-side SDKs):
// Add a custom notification directly to a user's notification feed
await serverClient.feeds.addActivity({
feeds: ["notification:user-123"], // Target user's notification feed
type: "milestone", // Custom activity type
text: "You've reached 1000 followers!",
user_id: "user_id",
extra_data: {
milestone_type: "followers",
count: 1000,
},
});
// Add activity to custom notification feed group
await serverClient.feeds.addActivity({
feeds: ["alerts:user-123"], // Custom notification feed group
type: "system_alert",
text: "Your subscription expires in 3 days",
user_id: "user_id",
});