React Native Push Notifications
TypeScript, RN 0.71+. Built on @react-native-firebase/messaging and react-native-callkeep.
⚛️ React Native
TypeScript, RN 0.71+. Built on @react-native-firebase/messaging and react-native-callkeep.
The SDK is free and open source (MIT) on GitHub. Create a free account to get your App ID.
Install
Set up Firebase following rnfirebase.io, then install @tingpush/react-native with its peer libraries:
Terminalnpm install @tingpush/react-native \ @react-native-firebase/app @react-native-firebase/messaging \ react-native-callkeep react-native-voip-push-notification \ @react-native-async-storage/async-storage react-native-device-info cd ios && pod install
React Native 0.71+, @react-native-firebase 22+. Expo needs a development build (it doesn't run in Expo Go).
Background handler in index.js
index.js// index.js — register BEFORE AppRegistry import { AppRegistry } from 'react-native'; import TingPush from '@tingpush/react-native'; import App from './App'; import { name as appName } from './app.json'; TingPush.registerBackgroundHandler(); // Android: show the call screen AppRegistry.registerComponent(appName, () => App);Initialize in the root component
App.tsximport { useEffect } from 'react'; import TingPush from '@tingpush/react-native'; export default function App() { useEffect(() => { TingPush.initialize( { appId: 'YOUR_APP_ID', appName: 'MyApp' }, { onCallEvent: ({ action, call }) => { if (action === 'accepted') { // User tapped Answer → connect the call (call.id, call.data.room) } }, // User tapped a notification (even when the app was closed) onNotificationOpened: (n) => { /* navigate using n.data.screen */ }, // Notification received while the app is open onNotificationReceived: (n) => { /* n.title, n.body, n.data */ }, }, ); }, []); // ... }Notifications while the app is open: iOS shows a banner if
firebase.jsonhas"react-native": { "messaging_ios_foreground_presentation_options": ["badge", "sound", "list", "banner"] }; Android doesn't show them — useonNotificationReceivedto show them in-app.Assign the user at login
TypeScriptawait TingPush.login('user-123'); // after login await TingPush.logout(); // on logout await TingPush.setTags({ plan: 'vip' }); TingPush.endCall(callId); // end the calliOS: enable capabilities and update AppDelegate (for calls)
Xcode → Signing & Capabilities: Push Notifications and Background Modes (Remote notifications + Voice over IP). VoIP pushes must be reported to CallKit in native code:
ios/AppDelegate.mm// AppDelegate.mm #import <PushKit/PushKit.h> #import "RNCallKeep.h" #import "RNVoipPushNotificationManager.h" @interface AppDelegate () <PKPushRegistryDelegate> @end // In didFinishLaunchingWithOptions, before return: // [RNVoipPushNotificationManager voipRegistration]; - (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(PKPushType)type { [RNVoipPushNotificationManager didUpdatePushCredentials:credentials forType:(NSString *)type]; } - (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion { NSDictionary *p = payload.dictionaryPayload; NSString *uuid = p[@"call_id"] ?: [[NSUUID UUID] UUIDString]; NSString *name = p[@"caller_name"] ?: @""; NSString *handle = p[@"caller_handle"] ?: name; BOOL hasVideo = [p[@"is_video"] isEqualToString:@"true"]; [RNVoipPushNotificationManager didReceiveIncomingPushWithPayload:payload forType:(NSString *)type]; [RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:hasVideo localizedCallerName:name supportsHolding:NO supportsDTMF:NO supportsGrouping:NO supportsUngrouping:NO fromPushKit:YES payload:p withCompletionHandler:completion]; }AppDelegate.swift (RN 0.77+): do the same and add the headers to your bridging header.
Android: declare the ConnectionService
android/app/src/main/AndroidManifest.xml<uses-permission android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.CALL_PHONE" /> <application> <service android:name="io.wazo.callkeep.VoiceConnectionService" android:label="Wazo" android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE" android:foregroundServiceType="camera|microphone" android:exported="true"> <intent-filter><action android:name="android.telecom.ConnectionService" /></intent-filter> </service> <service android:name="io.wazo.callkeep.RNCallKeepBackgroundMessagingService" /> </application>On first run Android asks for the "calling accounts" permission; some phones need it enabled under Settings → Calling apps.
✅ After integrating, check
- Run the app on a real device with logging on: you should see
[TingPush] Device registered …. - The project's Devices tab: the device appears; iOS devices show the VoIP badge if you use calls.
- The Send tab: send a test to that device.
- Choose 📞 Call and test with the app open, closed and with the screen locked.