Skip to content

Commit 8929ba0

Browse files
authored
docs: update readme for background call handling on ios (#170)
1 parent c33f194 commit 8929ba0

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,11 @@ connection while in the background. The example uses
382382
[react-native-callkeep](https://github.com/react-native-webrtc/react-native-callkeep)
383383
for simple integration with CallKit.
384384

385-
Our example code can be found [here](https://github.com/livekit/client-sdk-react-native/blob/main/example/src/callservice/CallService.android.ts).
385+
Our example code can be found [here](https://github.com/livekit/client-sdk-react-native/blob/main/example/src/callservice/CallService.ios.ts).
386+
387+
For apps planning to use CallKit to handle incoming calls in the background, [it is important to call
388+
`RTCAudioSession.audioSessionDidActivate/Deactivate` when the call provider activates/deactivates
389+
the audio session.](https://github.com/livekit/react-native-webrtc/blob/master/Documentation/iOSInstallation.md#callkit)
386390

387391
## Troubleshooting
388392

example/src/callservice/CallService.ios.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import RNCallKeep, {
55
AudioSessionMode,
66
} from 'react-native-callkeep';
77

8+
import { RTCAudioSession } from '@livekit/react-native-webrtc';
9+
810
let uuid = '1932b99c-4fe1-4bf4-897f-763bc4dc21c2';
911

1012
// This keeps the app alive in the background.
@@ -50,5 +52,13 @@ export function setupCallService() {
5052
},
5153
};
5254
RNCallKeep.setSettings(options);
53-
RNCallKeep.addEventListener('didChangeAudioRoute', () => {});
55+
RNCallKeep.addEventListener('didChangeAudioRoute', () => {}); // To quell warnings.
56+
57+
// For apps handling incoming calls from the background.
58+
RNCallKeep.addEventListener('didActivateAudioSession', () => {
59+
RTCAudioSession.audioSessionDidActivate();
60+
});
61+
RNCallKeep.addEventListener('didDeactivateAudioSession', () => {
62+
RTCAudioSession.audioSessionDidDeactivate();
63+
});
5464
}

0 commit comments

Comments
 (0)