# Proximity Policies

The StreamVideo SDK provides a flexible mechanism for handling device proximity changes during calls through its `ProximityPolicy` protocol. These policies allow you to automatically adjust call settings based on whether the device is near or far from the user (e.g., when holding the phone to the ear).

## Built-In Policies

### VideoProximityPolicy

Automatically manages video settings based on device proximity:

- When device is near (e.g., during phone call):
  - Disables video
  - Disables incoming video quality
- When device moves away:
  - Restores previous video settings
  - Restores previous incoming video quality settings

This policy is useful for conserving battery and data when the user is not looking at the screen.

#### Example usage

```swift
let call = streamVideo.call(callType: "default", callId: "chat-123")
let policy = VideoProximityPolicy()

do {
    try call.addProximityPolicy(policy)
} catch {
    log.error(error)
}
```

### SpeakerProximityPolicy

Manages speaker state based on device proximity:

- When device is near (e.g., during phone call):
  - Disables speaker if it was enabled
  - Stores previous speaker settings
- When device moves away:
  - Restores previous speaker settings

This policy ensures proper audio routing when the user holds the phone to their ear.

#### Example usage

```swift
let call = streamVideo.call(callType: "default", callId: "team-meet")
let policy = SpeakerProximityPolicy()

do {
    try call.addProximityPolicy(policy)
} catch {
    log.error(error)
}
```

## When to Use Each Policy

- **VideoProximityPolicy**: Use when you want to automatically disable video when the user holds the phone to their ear, improving battery life and data usage.
- **SpeakerProximityPolicy**: Use when you want to automatically switch between speaker and earpiece audio based on device proximity.

## Using Multiple Policies

You can combine multiple proximity policies for a call:

```swift
let call = streamVideo.call(callType: "default", callId: "chat-123")
let videoPolicy = VideoProximityPolicy()
let speakerPolicy = SpeakerProximityPolicy()

do {
    try call.addProximityPolicy(videoPolicy)
    try call.addProximityPolicy(speakerPolicy)
} catch {
    log.error(error)
}
```

## Conclusion

By implementing appropriate ProximityPolicies, you can create a more intuitive and power-efficient calling experience that automatically adapts to how users interact with their devices during calls.


---

This page was last updated at 2026-03-13T13:18:12.357Z.

For the most recent version of this documentation, visit [https://getstream.io/video/docs/ios/advanced/proximity-policies/](https://getstream.io/video/docs/ios/advanced/proximity-policies/).