# `Dala.Permissions`
[🔗](https://github.com/manhvu/dala/blob/main/lib/dala/permissions.ex#L1)

Permission management for Dala plugins.

Provides a unified interface for requesting and checking permissions
across iOS and Android. Maps permission atoms to platform-specific
permission strings and handles runtime request flows.

## Supported Permissions

- `:camera` — Camera access
- `:microphone` — Microphone access
- `:bluetooth` — Bluetooth access
- `:location` — Location services
- `:storage` — File/storage access
- `:photos` — Photo library access
- `:contacts` — Contacts access
- `:notifications` — Push notifications
- `:nfc` — NFC tag reading

## Usage

    # Request a permission at runtime — pass the screen pid
    # The result arrives as {:permission_result, permission, result} via handle_info/2
    Dala.Permissions.request(self(), :camera)

    # Check if a permission is granted
    Dala.Permissions.check(:camera)

    # Get all supported permissions
    Dala.Permissions.supported_permissions()

# `permission`

```elixir
@type permission() ::
  :camera
  | :microphone
  | :bluetooth
  | :location
  | :storage
  | :photos
  | :contacts
  | :notifications
  | :nfc
```

# `android_permission`

```elixir
@spec android_permission(permission()) :: String.t() | nil
```

Returns the Android permission string.

# `check`

```elixir
@spec check(permission()) :: :granted | :denied
```

Checks if a permission is currently granted. Returns `:granted` or `:denied`.

# `ios_plist_key`

```elixir
@spec ios_plist_key(permission()) :: String.t() | nil
```

Returns the iOS plist key for a permission.

# `permission_string`

```elixir
@spec permission_string(permission()) :: String.t()
```

Returns the platform-specific permission string.

# `request`

```elixir
@spec request(pid(), permission()) :: :ok | {:error, term()}
```

Requests a permission from the OS.

`pid` is the process that will receive the result message
`{:permission_result, permission, result}` — typically the screen process (`self()`).

Returns `:ok` immediately; the actual permission result arrives asynchronously
via the pid's mailbox.

# `supported?`

```elixir
@spec supported?(permission()) :: boolean()
```

Checks if a permission is supported.

# `supported_permissions`

```elixir
@spec supported_permissions() :: [permission()]
```

Returns all supported permissions.

# `validate_permissions`

```elixir
@spec validate_permissions([permission()]) :: :ok | {:error, term()}
```

Validates permissions, returning `:ok` or `{:error, {:unsupported, [permissions]}}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
