Overview
Ant Media Server supports push notifications to notify mobile app users about stream events in real-time. This feature integrates with:- Firebase Cloud Messaging (FCM) - For Android and iOS apps
- Apple Push Notification (APN) - For iOS apps
- Notify users when a streamer goes live
- Alert viewers about stream status changes
- Send custom messages during broadcasts
- Trigger app actions from server events
Architecture
The push notification system uses a service interface pattern:Firebase Cloud Messaging (FCM) Setup
Prerequisites
1
Create Firebase Project
- Go to Firebase Console
- Click Add Project
- Enter project name and follow setup wizard
2
Get Service Account Key
- Navigate to Project Settings → Service Accounts
- Click Generate New Private Key
- Save the JSON file securely
3
Upload to Ant Media Server
Upload the service account JSON file to:
Configuration
Enable FCM in application settings:Apple Push Notification (APN) Setup
Prerequisites
1
Create APN Key
- Go to Apple Developer Portal
- Click + to create a new key
- Enable Apple Push Notifications service (APNs)
- Download the
.p8key file
2
Note Your Credentials
You’ll need:
- Key ID - From the downloaded key filename
- Team ID - From Apple Developer account
- Bundle ID - Your iOS app’s bundle identifier
3
Upload Key to Server
Configuration
Set
apnProduction to true for production apps, false for development/sandbox.Sending Notifications
Via REST API
Programmatic Usage
Message Format
Standard Fields
Custom Data
Add any custom fields for your app logic:Topic Management
Subscribe Users to Topics
Manage topic subscriptions from your mobile app:- Android (FCM)
- iOS (FCM)
Topic Naming Conventions
Organize topics logically:Integration with Stream Events
Automatic Notifications
Trigger notifications on stream events using webhooks:Supported Events
Mobile App Implementation
Android (FCM)
iOS (APN)
Testing Notifications
Test FCM
Test APN
Troubleshooting
Notifications not received (FCM)
Notifications not received (FCM)
Check:
- Service account JSON file is correct and in right location
- Device/app is subscribed to the topic
- FCM token is valid and not expired
- App has notification permissions
Notifications not received (APN)
Notifications not received (APN)
Common issues:
- Using production key with development app (or vice versa)
- Wrong bundle ID
- Invalid .p8 key file
- Device token format incorrect
- Match
apnProductionsetting with app build type - Verify bundle ID matches app’s bundle identifier
- Regenerate .p8 key if necessary
- Ensure device token is properly formatted (no spaces/special chars)
High notification latency
High notification latency
Causes:
- Network issues between AMS and FCM/APN servers
- Rate limiting by FCM/APN
- Server overload
- Check server internet connectivity
- Implement batching for bulk notifications
- Monitor notification send rates
Best Practices
Personalize Messages
Use subscriber-specific data to make notifications relevant. Include streamer names, custom actions, etc.
Rate Limiting
Don’t spam users. Implement throttling for frequent events like viewer count updates.
Action Buttons
Include actionable data in notifications so users can directly interact (watch stream, reply, etc.).
Analytics
Track notification delivery rates and user engagement to optimize messaging strategy.
