---
title: "setActive:error:"
framework: avfaudio
role: symbol
role_heading: Instance Method
path: "avfaudio/avaudiosession/setactive:error:"
---

# setActive:error:

Activates or deactivates your app’s audio session.

## Declaration

```occ
- (BOOL) setActive:(BOOL) active error:(NSError **) outError;
```

## Parameters

- `active`: Use doc://com.apple.documentation/documentation/Swift/true to activate your app’s audio session, or doc://com.apple.documentation/documentation/Swift/false to deactivate it.
- `outError`: On input, a pointer to an error object. If an error occurs, the framework sets the pointer to an doc://com.apple.documentation/documentation/Foundation/NSError object that describes the error. If you don’t want error information, pass in nil.

## Return Value

Return Value true if the system successfully changed the active state; otherwise false.

## Discussion

Discussion Your app may activate a session with category playback when another app is hosting a call, for example to start a SharePlay activity. However, your app isn’t permitted to capture the microphone of the active call. note: If you attempt to activate a session with category record or playAndRecord when another app is already hosting a call, then your session fails with the error AVAudioSessionErrorInsufficientPriority. The session fails to activate if another audio session has higher priority than yours (such as a phone call) and neither audio session allows mixing. Deactivating an audio session with running audio objects stops the objects, makes the session inactive, and returns an AVAudioSession.ErrorCode.isBusy error. When your app deactivates a session, the return value is false but the active state changes to deactivate.

## See Also

### Activating the audio configuration

- [setActive(_:options:)](avfaudio/avaudiosession/setactive(_:options:).md)
- [activate(options:completionHandler:)](avfaudio/avaudiosession/activate(options:completionhandler:).md)
- [deactivate(options:completionHandler:)](avfaudio/avaudiosession/deactivate(options:completionhandler:).md)
- [AVAudioSessionActivationOptions](avfaudio/avaudiosessionactivationoptions.md)
- [AVAudioSessionDeactivationOptions](avfaudio/avaudiosessiondeactivationoptions.md)
