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:- Telnyx Portal Configuration: Push certificates and FCM keys configured in your Telnyx portal
- Development Environment: React Native development environment set up for both platforms
- Firebase Project (Android): Firebase project created with FCM enabled
- 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
- Download the
google-services.jsonfile from your Firebase project console - Place it in your project root directory (same level as
package.json)
Step 2: Configure Firebase in Android Manifest
Ensure yourandroid/app/src/main/AndroidManifest.xml includes Firebase services:
3. Native Implementation
Android Implementation
Step 1: Extend TelnyxMainActivity
Your app’sMainActivity should extend TelnyxMainActivity for automatic push notification handling:
- Automatic push notification intent handling
- Call action processing (Answer/Decline from notifications)
- Proper lifecycle management for VoIP functionality
- Integration with
VoicePnManagerfor push notification state
Step 2: Create Firebase Messaging Service
Create a Firebase messaging service that extendsTelnyxFirebaseMessagingService:
Step 3: Create Notification Action Receiver
Create a notification action receiver for handling notification actions:iOS Implementation
Step 1: Configure AppDelegate
YourAppDelegate should implement PKPushRegistryDelegate and delegate to TelnyxVoipPushHandler:
- CallKit integration is automatically handled by the internal
CallBridgecomponent - You don’t need to implement any CallKit delegate methods manually
- Audio session management is automatically handled
- The
TelnyxVoipPushHandlermanages all VoIP push notification processing
Step 2: Configure Info.plist
Add the required background modes to yourios/YourApp/Info.plist:
4. JavaScript/TypeScript Integration
Step 1: Configure TelnyxVoiceApp
Wrap your app withTelnyxVoiceApp 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)
Step 3: 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 theVoipTokenFetcher component:
VoipTokenFetcher component automatically:
- Requests notification permissions
- Retrieves FCM tokens (Android) and VoIP tokens (iOS)
- Handles platform-specific token registration
Step 4: Authentication
Include push tokens in your login configuration:Configuration Options
TelnyxVoiceApp Configuration
VoIP Client Configuration
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:- Android: Extend
TelnyxMainActivityandTelnyxFirebaseMessagingService - iOS: Implement
PKPushRegistryDelegateand delegate toTelnyxVoipPushHandler - Both: Wrap your app with
TelnyxVoiceAppand 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.jsonis in the correct location - Check Firebase project configuration and FCM keys in Telnyx portal
- Ensure
AppFirebaseMessagingServiceis properly registered in AndroidManifest.xml - Verify app is not in battery optimization/doze mode
- 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
MainActivityextendsTelnyxMainActivity - Check intent filters in AndroidManifest.xml
- Ensure
onHandleIntentis properly implemented
- 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
- Token Storage: Push tokens are automatically stored securely by the SDK
- Certificate Management: Keep VoIP certificates and FCM keys secure
- Authentication: Ensure proper authentication before accepting calls
- Network Security: Use secure connections for all Telnyx communications
Next Steps
After completing the app setup:- Test Push Notifications: Test with both foreground and background scenarios
- Call Flow Testing: Verify complete call flow from push to termination
- Production Deployment: Configure production certificates and keys
- Monitoring: Implement logging and monitoring for production use