Overview
The Push Notifications API allows you to send notifications to subscribers using configured push notification services (FCM, APNS, etc.). All endpoints are prefixed with/v2/push-notification.
Get Subscriber Authentication Token
Generate a JWT authentication token for a subscriber.GET /v2/push-notification/subscriber-auth-token
Subscriber ID to generate token for
Token validity duration in seconds (default: 1 hour)
Whether token generation succeeded
The generated JWT token
Description: “Token is available in dataId field”
Send Notification to Subscribers
Send a push notification to specific subscribers.POST /v2/push-notification/subscribers
Array of subscriber IDs to send notification to
JSON-formatted notification message as a string
Name of the push notification service to use. If not specified, uses the default service.
Whether notification was sent successfully
Result message or error description
Send Notification to Topic
Send a push notification to all subscribers of a topic.POST /v2/push-notification/topics/{topic}
Topic name to send notification to
Notification title
Notification message body
Additional data payload for the notification
Name of the push notification service to use
Whether notification was sent successfully
Result message or error description
Push Notification Services
Supported Services
Ant Media Server supports multiple push notification services:- FCM (Firebase Cloud Messaging) - For Android and iOS
- APNS (Apple Push Notification Service) - For iOS
- Custom notification services via plugins
Configuration
Push notification services must be configured in the application settings before use. Each service requires specific credentials: FCM Configuration:- Service account JSON file
- Project ID
- Certificate file
- Private key
- Team ID
- Bundle ID
Service Selection
If multiple notification services are configured:- Without
serviceNameparameter: Uses the default/first configured service - With
serviceNameparameter: Uses the specified service
Notification Message Format
Standard Fields
Most push notification services support these standard fields:Notification title displayed prominently
Main notification message text
URL to an image to display in the notification
Custom data payload passed to the app
FCM-Specific Fields
For Firebase Cloud Messaging, you can include:Use Cases
Notify Subscribers When Stream Starts
Notify Topic Subscribers
Error Handling
Common Errors
Invalid JSON Message:Best Practices
- Validate JSON - Ensure your notification message is valid JSON before sending
- Handle errors gracefully - Check the
successfield in responses - Batch notifications - Send to multiple subscribers in one request when possible
- Use topics - For broadcasting to many users, use topic-based notifications
- Include data payload - Add context data so the app can handle the notification appropriately
Integration with Subscribers
Push notifications work in conjunction with the Subscriber API. To enable notifications for a subscriber:- Add subscriber to a stream using
/v2/broadcasts/{id}/subscribers - Configure subscriber’s push notification token/device ID
- Send notifications when events occur (stream start, messages, etc.)
