Skip to main content

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
Use cases include:
  • 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

  1. Go to Firebase Console
  2. Click Add Project
  3. Enter project name and follow setup wizard
2

Get Service Account Key

  1. Navigate to Project Settings → Service Accounts
  2. Click Generate New Private Key
  3. 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

  1. Go to Apple Developer Portal
  2. Click + to create a new key
  3. Enable Apple Push Notifications service (APNs)
  4. Download the .p8 key 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:

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

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
Debug:
Common issues:
  • Using production key with development app (or vice versa)
  • Wrong bundle ID
  • Invalid .p8 key file
  • Device token format incorrect
Solutions:
  • Match apnProduction setting 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)
Causes:
  • Network issues between AMS and FCM/APN servers
  • Rate limiting by FCM/APN
  • Server overload
Solutions:
  • 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.