← Back to notebook index

Notebook Topic

Camera Photo Library

English topic guide inspired by the original iOS Developer Notebook, expanded for both iOS and Android teams.

What this topic covers

Execution checklist

iOS implementation notes

Android implementation notes

Code examples

Swift

import PhotosUI
@State private var item: PhotosPickerItem?
PhotosPicker("Select photo", selection: $item, matching: .images)
  .onChange(of: item) { _ in Task { _ = try? await item?.loadTransferable(type: Data.self) } }

Kotlin

val launcher = rememberLauncherForActivityResult(ActivityResultContracts.PickVisualMedia()) { uri ->
  uri?.let { viewModel.onImageSelected(it) }
}
launcher.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))

Reference links

Related topics