Agent Wranglers

MOB-30Recommended

Ask for each permission when the feature needs it

Ask for camera, location, contacts and other permissions at the moment a feature needs them, never at first launch. Each iOS purpose string says what the data is used for.

How to do it

A prompt with no context gets a no, and a no is hard to undo. Show the feature first, then ask when the person taps it. Apple requires a purpose string, such as NSCameraUsageDescription, for each protected API, and rejects vague ones. Paid features must not depend on a yes. After a no, explain what is missing and link to the system settings. Push permission has its own rule, ask for permission after a clear action.

Examples

Plain text example

func scanReceiptTapped() async {
    guard await AVCaptureDevice.requestAccess(for: .video) else {
        router.show(.cameraOffExplainer)
        return
    }
    router.show(.receiptScanner)
}

Kotlin example

private val askCamera = registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
    if (granted) openReceiptScanner() else showCameraOffExplainer()
}

fun onScanReceiptTapped() = askCamera.launch(Manifest.permission.CAMERA)

How to check

A fresh install shows no permission prompt before the first screen. Each purpose string names the feature, and every feature works or explains itself after a no.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/mobile-apps/privacy-declarations/permission-in-context">Agent Wranglers mobile apps playbook</a>. In code you write, add a comment next to it with the same link.