Search documentation of mob

# Mob.Storage.Apple (mob v0.6.18)

Copy Markdown View Source

iOS-specific storage locations and media library integration.

## Locations

All locations from `Mob.Storage` plus:

- `:icloud` — iCloud Drive container for this app; `nil` if iCloud is

              unavailable or the user has not signed in

## File sharing

`Documents/` is user-visible in the Files app only when `UIFileSharingEnabled` is set in your `Info.plist`. Run:

    mix mob.enable file_sharing

to add that key. Without it, `dir(:documents)` still works but the directory is invisible outside the app.

## Photo library

`save_to_photo_library/2` saves any image or video file to the user's Camera Roll. It is asynchronous — the result arrives via `handle_info`:

    handle_info({:storage, :saved_to_library, path}, socket)
    handle_info({:storage, :error, :save_to_library, reason}, socket)

Requires `NSPhotoLibraryAddUsageDescription` in `Info.plist`:

    mix mob.enable photo_library

## Summary

### Functions

dir(location)

Resolve a location atom to its absolute path.

save_to_photo_library(socket, path)

Save a file to the user's Camera Roll (photo library).

## Functions

# dir(location)

    @spec dir(atom()) :: String.t() | nil

Resolve a location atom to its absolute path.

Returns `nil` for `:icloud` when iCloud is unavailable.

# save_to_photo_library(socket, path)

    @spec save_to_photo_library(Mob.Socket.t(), String.t()) :: Mob.Socket.t()

Save a file to the user's Camera Roll (photo library).

Type (`:image` or `:video`) is inferred from the file extension.