Camera & media
Take photos, capture a screenshot, record audio, and scan barcodes from the device.
Take a photo
Open the camera to take a photo. The image arrives on the photoCaptured event, so subscribe before you call, and ask for camera permission first.
capturePhoto emits photoCaptured; pickPhoto emits photoSelected. They are not interchangeable.
Use the photo result
The photoCaptured listener receives a MediaResult. Use dataUri to preview inline and fileUrl to upload. bdk.on(...) returns an unsubscribe function.
Pick from the photo library
Open the photo library instead of the camera. Results arrive on the photoSelected event, not photoCaptured.
Take a screenshot
Capture a screenshot of the current screen. The image arrives on the screenshot event.
Record audio
Open the native audio recorder. The recording arrives on the audioRecorded event as a MediaResult — use fileUrl to upload it.
Scan a barcode
Open the scanner for QR codes and barcodes. The decoded value arrives on the barcodeScanned event.
Fall back on the web
Outside the app the call resolves with triggered: false and photoCaptured never fires. Detect this and show a standard <input type="file" capture> instead.
Pick multiple photos
Open the system photo picker so the user can select more than one image. Unlike the helpers above, the photos arrive on the awaited call — there is no event.
Success is { ok: true, selectedCount, succeededCount, failedCount, items } — each item is a JPEG BdkMediaItem. If the user cancels, the call resolves ok: false with code: "common/cancelled"; treat that as a normal outcome.
This feature can be switched off in a given app build. Check await bdk.capabilities.has("media") before showing the UI — see Detect features. When it's off, the call resolves ok: false with code: "common/feature_disabled". Builds can cap the limit and disable file URLs.
Take a photo from the camera
Open the system camera and take one photo. The image arrives on the awaited call as a single BdkMediaItem — no event. camera is back or front; on Android it is a best-effort hint.
The same result, maxDimensionPx, and jpegQuality options as Pick multiple photos apply.
Show a photo
Turn a picked or captured item into a data URI you can put in an <img>. The call is synchronous and returns null when the item is file-URL-only.