I am using ‘expo-av’ in a bare react-native project to record audio. It is working fine on Android and 50% of the time on IOS.
The other 50% of the time it give the error.
prepare encountered an error: Error Domain=NSOSStatus error-Domain Code=561017449″Session Activation Failed”
I have searched long and hard so far my theory is that when some App or Service is using audio related API in the device it throws this error, but to handle this or check if the service is available or not there is not API provided by the “expo-av” library.
Can anyone give me useful insights or solutions to what is happening.
here is the recording function I am using to start the recording.
const startRecording = async () => {
try {
// Request microphone permissions
if (permissionResponse.status !== 'granted') {
console.log('Requesting permission..');
await requestPermission();
}
// Prepare audio recording options
await Audio.setAudioModeAsync({
allowsRecordingIOS: true,
playsInSilentModeIOS: true,
interruptionModeIOS: InterruptionModeIOS.DoNotMix,
interruptionModeAndroid: InterruptionModeAndroid.DoNotMix,
playsInSilentModeIOS: true,
staysActiveInBackground: true,
});
// Start recording
const {recording} = await Audio.Recording.createAsync(
Audio.RecordingOptionsPresets.HIGH_QUALITY,
);
setRecording(recording);
setIsRecording(true);
setIsPaused(false);
console.log('Recording started');
} catch (err) {
Alert.alert('Failed to start Recording: ' + err?.message);
console.error('Failed to start recording', err);
}
};
Below are the versions:
“expo”: “^52.0.0”,
“expo-av”: “~15.0.1”,
“react”: “18.3.1”,
“react-native”: “0.76.5”,