Calls / React Native
Calls React Native v1
Calls React Native
Calls
React Native
Home
/
Calls
/
React Native
/
Direct call

Add push notifications

After you have authenticated the client app and the user, set up notifications and register push tokens for the user to receive push notifications on the device. Push tokens allow the client app to receive notifications about an incoming 1-to-1 call when the app is running in the background or closed.


For iOS

You can set up push notifications using either VoIP or remote notifications. To use either type of notifications, add your APNs certificate on Sendbird Dashboard and register a user’s push token to Sendbird server. To add your certificate on the dashboard, select an application, go to Settings > Calls > Notifications > Add credential.

To receive push notifications using VoIP, add CallKit and PushKit. Then, enable Background Modes on your Xcode project’s Signing & Capabilities to support background operations using VoIP. Select the Voice over IP option under the list of available modes.

Add the user’s device token to the server to receive a 1-to-1 call. Call the SendbirdCalls.ios_registerVoIPPushToken() method to register the push token for VoIP.

// Update VoIP push token.
if (Platform.OS === 'ios') {
 RNVoipPushNotification.addEventListener('register', async (voipToken) => {
   await SendbirdCalls.ios_registerVoIPPushToken(voipToken);
   // The VoIP push token has been registered successfully.
 });
 RNVoipPushNotification.registerVoipToken();
}

To receive push notifications using remote notifications, go to your Xcode project’s Signing & Capabilities and enable Remote notifications. Use the SendbirdCalls.registerPushToken() method to add a token with remote notifications.

// Update APNs push token.
if (Platform.OS === 'ios') {
 const apnsToken = await messaging().getAPNSToken();
 await SendbirdCalls.registerPushToken(apnsToken);
 // The APNs Push Token has been registered successfully.
}

For detailed information about differences between the two types of notifications and push notifications registration, see the notifications page.


For Android

You can set up push notifications using FCM by adding your server key on Sendbird Dashboard and registering a FCM push token to the Sendbird Server. To add your certificate on the dashboard, select an application, go to Settings > Calls > Notifications > Add credential. Call the SendbirdCalls.registerPushToken() method to register the push token.

// Update FCM push token.
if (Platform.OS === 'android') {
 const fcmToken = await messaging().getToken();
 await SendbirdCalls.registerPushToken(fcmToken);
 // The FCM push token has been registered successfully.
}

For detailed information about push notification registration, see the notifications page.