Skip to main content

Push Notification App Setup

This guide covers the complete setup required in your React Native application to enable push notifications for incoming calls using the @telnyx/react-voice-commons-sdk.

Overview

The Telnyx React Voice Commons SDK provides comprehensive push notification support for both iOS and Android platforms:
  • iOS: Uses Apple Push Notification Service (APNs) with VoIP certificates for instant call delivery
  • Android: Uses Firebase Cloud Messaging (FCM) for background call notifications
  • Background Handling: Automatic call processing when app is in background or terminated
  • Native Call UI: Integration with CallKit (iOS) and ConnectionService (Android)
  • Multidevice Support: Up to 5 devices can receive push notifications for the same user

Multidevice Push Notifications

Telnyx WebRTC supports multidevice push notifications. A single user can have up to 5 device tokens (either iOS - APNs or Android - FCM). When a user logs into the socket and provides a push token, our services will register this token to that user - allowing it to receive push notifications for incoming calls. If a 6th registration is made, the least recently used token will be removed. This effectively means that you can have up to 5 devices that can receive push notifications for the same incoming call.

Prerequisites

Before implementing push notifications, ensure you have:
  1. Telnyx Portal Configuration: Push certificates and FCM keys configured in your Telnyx portal
  2. Development Environment: React Native development environment set up for both platforms
  3. Firebase Project (Android): Firebase project created with FCM enabled
  4. Apple Developer Account (iOS): VoIP push certificates configured
Note: For portal configuration instructions, see Portal Setup.

Application Setup

1. Install Dependencies

The SDK requires specific dependencies for push notification handling:

2. Firebase Configuration (Android)

Step 1: Download Configuration File

  1. Download the google-services.json file from your Firebase project console
  2. Place it in your project root directory (same level as package.json)

Step 2: Configure Firebase in Android Manifest

Ensure your android/app/src/main/AndroidManifest.xml includes Firebase services:

3. Native Implementation

Android Implementation

Step 1: Extend TelnyxMainActivity

Your app’s MainActivity should extend TelnyxMainActivity for automatic push notification handling:
Key Features Provided by TelnyxMainActivity:
  • Automatic push notification intent handling
  • Call action processing (Answer/Decline from notifications)
  • Proper lifecycle management for VoIP functionality
  • Integration with VoicePnManager for push notification state

Step 2: Create Firebase Messaging Service

Create a Firebase messaging service that extends TelnyxFirebaseMessagingService:

Step 3: Create Notification Action Receiver

Create a notification action receiver for handling notification actions:

iOS Implementation

Step 1: Configure AppDelegate

Your AppDelegate should implement PKPushRegistryDelegate and delegate to TelnyxVoipPushHandler:
Important Notes:
  • CallKit integration is automatically handled by the internal CallBridge component
  • You don’t need to implement any CallKit delegate methods manually
  • Audio session management is automatically handled
  • The TelnyxVoipPushHandler manages all VoIP push notification processing

Step 2: Configure Info.plist

Add the required background modes to your ios/YourApp/Info.plist:

4. JavaScript/TypeScript Integration

Step 1: Configure TelnyxVoiceApp

Wrap your app with TelnyxVoiceApp for automatic lifecycle management:

Step 2: No Background Handler Required

Android push notifications are handled automatically by the SDK’s native components. You don’t need to register any background message handlers in your JavaScript code. The SDK handles everything natively through:
  • TelnyxMainActivity (extends your MainActivity)
  • TelnyxFirebaseMessagingService (extends your FCM service)
Simply extend these classes as shown in the native implementation steps above, and push notifications will work automatically. Do not call messaging().setBackgroundMessageHandler(...) from @react-native-firebase/messaging. There is no JS-side TelnyxVoiceApp.handleBackgroundPush step to wire up — a JS handler will fight the native service and can double-process or drop incoming calls.

Step 3: Detect Push-Launched Cold Starts (Avoid Double-Login)

When the OS wakes your app from a terminated state to deliver an incoming call, the SDK is already handling the login internally as part of the push flow. If your app also triggers its own login* call on mount, you end up with two competing sessions — this is the single most common integration bug. Use the static method TelnyxVoipClient.isLaunchedFromPushNotification() to guard your own auto-login:
How it works: the method is static (callable before the client is constructed) and returns true when there is a pending FCM intent (Android) or PushKit payload (iOS) that has not yet been consumed by the SDK. It works on both platforms. Common mistake — manual or automatic login on push:
Symptoms of double-login: the incoming call rings briefly then disappears, the socket disconnects mid-call, CallKit shows a call that immediately ends, or you see rapid CONNECTED → DISCONNECTED → CONNECTED cycles in the logs right after a push is delivered. If you hit these, audit every useEffect in your app for an unguarded login* call on mount. Applies to any login entry point — including login forms that re-submit stored credentials, splash screens that eagerly log in, and background tasks that refresh tokens. What to observe after the SDK finishes the push login:
  • voipClient.connectionState$ → emits CONNECTED (there is no separate loginState$CONNECTED means socket up and authenticated).
  • voipClient.activeCall$ → emits the Call once the SDK has processed the push.
  • voipClient.currentActiveCall → synchronous accessor; on push-launched mounts the call may already be present by the time you subscribe, so check this first.
CallKit (iOS) and ConnectionService (Android) already render the native incoming-call UI; this RN-side navigation only matters once the user taps into the app.

Step 4: Token Registration (Optional)

Push tokens are handled automatically by the SDK during authentication. For most apps, you don’t need to do anything additional. If you want to handle push tokens manually (for logging or custom logic), you can use the VoipTokenFetcher component:
The VoipTokenFetcher component automatically:
  • Requests notification permissions
  • Retrieves FCM tokens (Android) and VoIP tokens (iOS)
  • Handles platform-specific token registration

Step 5: Authentication

Include push tokens in your login configuration:

Configuration Options

TelnyxVoiceApp Configuration

VoIP Client Configuration

Configuration Options Explained:
  • enableAppStateManagement: true: Enables automatic background/foreground app state management. When enabled, the library automatically disconnects when the app goes to background (unless there’s an active call) and handles reconnection logic.
  • debug: true: Enables detailed logging for connection states, call transitions, and push notification processing.

Authentication with Push Tokens

Push tokens are automatically handled by the SDK. You only need to include the SDK and authenticate normally:

Credential-Based Authentication

Token-Based Authentication

What Happens Automatically

The SDK handles push notifications automatically once you:
  1. Android: Extend TelnyxMainActivity and TelnyxFirebaseMessagingService
  2. iOS: Implement PKPushRegistryDelegate and delegate to TelnyxVoipPushHandler
  3. Both: Wrap your app with TelnyxVoiceApp and authenticate with the SDK

Android Automatic Features

  • FCM token registration with Telnyx servers
  • Background push notification processing
  • Incoming call notifications with Answer/Decline buttons
  • App launching from terminated state
  • Call connection and audio setup

iOS Automatic Features

  • VoIP token registration with Telnyx servers
  • CallKit integration for native call UI
  • Background call processing
  • App launching from terminated state
  • Audio session management

Advanced Configuration

Custom FCM Message Handling (Android)

If you need to handle additional FCM messages beyond Telnyx voice calls, extend the service:

Push Notification Debugging

Enable comprehensive debugging for push notification issues:

Troubleshooting

Common Issues

Push Notifications Not Received

Android:
  • Verify google-services.json is in the correct location
  • Check Firebase project configuration and FCM keys in Telnyx portal
  • Ensure AppFirebaseMessagingService is properly registered in AndroidManifest.xml
  • Verify app is not in battery optimization/doze mode
iOS:
  • Ensure VoIP push certificates are configured in Apple Developer account
  • Verify certificates are uploaded to Telnyx portal
  • Check that TelnyxVoipPushHandler.initializeVoipRegistration() is called
  • Ensure app has proper VoIP background modes configured

App Not Launching from Push

Android:
  • Verify MainActivity extends TelnyxMainActivity
  • Check intent filters in AndroidManifest.xml
  • Ensure onHandleIntent is properly implemented
iOS:
  • Verify AppDelegate implements PKPushRegistryDelegate
  • Ensure proper delegation to TelnyxVoipPushHandler
  • Check VoIP background modes in Info.plist

Call Connection Issues

  • Verify authentication is successful before push notification
  • Check network connectivity and Telnyx service availability
  • Ensure proper error handling in push notification flow
  • Verify call state management in TelnyxVoiceApp

Debug Logging

Enable detailed logging to troubleshoot issues:

Security Considerations

  1. Token Storage: Push tokens are automatically stored securely by the SDK
  2. Certificate Management: Keep VoIP certificates and FCM keys secure
  3. Authentication: Ensure proper authentication before accepting calls
  4. Network Security: Use secure connections for all Telnyx communications

Next Steps

After completing the app setup:
  1. Test Push Notifications: Test with both foreground and background scenarios
  2. Call Flow Testing: Verify complete call flow from push to termination
  3. Production Deployment: Configure production certificates and keys
  4. Monitoring: Implement logging and monitoring for production use
For additional configuration and troubleshooting, see: