Calls history and call-back
With calls history enabled, the calls your app registers in CallKit and Telecom appear in the system call history: the Recents list of the iOS Phone app, and the call log of the Android dialer. When the user taps one of these entries, your app is opened and receives a call-back event, so you can call the same people again.
Enable calls history
Set callsHistory for each platform in your push configuration (React Native, Expo):
StreamVideoRN.setPushConfig({
ios: {
// ...
callsHistory: true,
},
android: {
// ...
callsHistory: true,
},
// ...
});The Android integration is built on Jetpack Telecom 1.1.0, which requires your app to compile against API 36.1 or newer, with Android Gradle Plugin 8.9.1+ and Kotlin 2.1+. React Native 0.88 and Expo 58 projects meet these requirements by default. In an older Expo project, raise compileSdkVersion with the expo-build-properties config plugin.
On Android, calls are added to the system call log on Android 16 QPR2 (API 36.1) and newer, and callsHistory has no effect on older versions. Your calls are listed only if the device's dialer shows VoIP calls in its call log.
Handle call-backs
When the user taps an entry of your app in the system call history, your app is opened and the callBackRequested event is emitted with the following parameters:
callId- the cid (type:id) of the call the entry belongs to.isVideo- whether the original call was a video call.displayName- the name shown for the entry, if available.
The SDK doesn't call back by itself, so you decide what to do: for example, fetch the original call and ring its members again in a new call.
The event is sticky. If the tap launched your app, the event is delivered to the first listener, even if that listener subscribes after the event arrived. You can subscribe once your video client is ready without missing a call-back.
import { useEffect } from "react";
import { CallingxModule } from "@stream-io/react-native-callingx";
import { useStreamVideoClient } from "@stream-io/video-react-native-sdk";
export const useCallBackEffect = () => {
const client = useStreamVideoClient();
useEffect(() => {
if (!client) return;
const subscription = CallingxModule.addEventListener(
"callBackRequested",
async ({ callId, isVideo }) => {
try {
const [callType, id] = callId.split(":");
if (!callType || !id) return;
// fetch the original call once, without watching its updates
const { calls } = await client.queryCalls({
filter_conditions: { cid: callId },
limit: 1,
watch: false,
});
const [original] = calls;
// the call was deleted or you no longer have access to it
if (!original) return;
const memberIds = original.state.members.map((m) => m.user_id);
const ownId = client.state.connectedUser?.id;
// nobody else to ring
if (!memberIds.some((memberId) => memberId !== ownId)) return;
// create a new call with the same members and ring them
await client.call(callType, crypto.randomUUID()).getOrCreate({
ring: true,
video: isVideo,
data: { members: memberIds.map((user_id) => ({ user_id })) },
});
} catch (error) {
console.warn("Failed to call back", error);
}
},
);
return () => subscription.remove();
}, [client]);
};Use the hook in a component rendered inside <StreamVideo>, so the client is available.
Always call back with a new call ID. Don't ring again with the callId from the event: that call has usually ended, and reusing it mixes the new call into the old call's state, history and recordings. Use the original call only to look up who to ring, then create a new call for them, as in the example above.
If the call was deleted or the user no longer has access to it, queryCalls returns no calls. Ended calls are still returned.
Platform setup
iOS
When the user taps an entry in Recents, iOS opens your app with a user activity. Forward it to the SDK.
Call-back from Recents works with the default CallKit integration only. If you set ios.useLiveCommunicationKit, your calls still appear in Recents, but tapping them doesn't emit callBackRequested.
Expo
If you use Expo, the config plugin does the iOS setup for you when the ringing property is enabled:
- it adds
INStartCallIntenttoNSUserActivityTypesin yourInfo.plist - it forwards user activities to the SDK from
application(_:continue:restorationHandler:)in yourAppDelegate.swift. Expo also delivers scene-based user activities (cold start and running app) to this method, so noSceneDelegatechanges are needed.
Run npx expo prebuild after enabling callsHistory so the native project is regenerated.
If the plugin can't find application(_:didFinishLaunchingWithOptions:) in your AppDelegate.swift, for example because it was customized, it shows a warning during prebuild and doesn't forward user activities. In that case, add the forwarding yourself as shown in Forward user activities.
Add the user activity type
This step and the next one are needed only in apps that don't use the Expo config plugin.
Add INStartCallIntent to NSUserActivityTypes in your Info.plist:
<key>NSUserActivityTypes</key>
<array>
<string>INStartCallIntent</string>
</array>Forward user activities
StreamVideoReactNative.handle(userActivity) returns true when the activity was a call-back from Recents, and false for any other activity, which you can pass on to your other handlers (for example RCTLinkingManager).
If your app uses the scene-based life cycle (a SceneDelegate), forward user activities both on a cold start and while the app is running:
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
// ... your existing setup
for userActivity in connectionOptions.userActivities {
if StreamVideoReactNative.handle(userActivity) { continue }
RCTLinkingManager.application(UIApplication.shared, continue: userActivity) { _ in }
}
}
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
if StreamVideoReactNative.handle(userActivity) { return }
RCTLinkingManager.application(UIApplication.shared, continue: userActivity) { _ in }
}If your app doesn't use scenes, forward them from your AppDelegate:
override func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
if StreamVideoReactNative.handle(userActivity) { return true }
return RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
}- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> *_Nullable))restorationHandler
{
if ([StreamVideoReactNative handleUserActivity:userActivity]) {
return YES;
}
return [RCTLinkingManager application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
}Android
No additional setup is needed, in React Native CLI or Expo apps. The SDK registers the call-back handler for you when callsHistory is enabled.