Permissions: ask at the right moment, and live with a no

A ticket app needs the camera to scan a QR code. Watch it ask too early and lose, ask at the right time and win, and see what iOS and Android each do when the answer is no.

Level: BasicWatch: 16 steps · ~1½ minutesPress the phone's buttons yourselfRecall: 3 questions · 8 cardsCompare 3 systemsTSX · AndroidManifest · Info.plist

What you'll take away

  • Ask for a permission when someone taps the feature, after one line on what it's for
  • Tell denied from blocked, and why iOS blocks after one no but Android 11+ after two
  • Know why check() on Android never says blocked, and why only request() finds out
  • Keep blocked from being a dead end: another way through, Settings, check() on return

The 1-minute version

Tap a point and the picture below plays that step.

4Compare them all
iOSthe app asks at launch
The OS's record for this app · camera: unasked
Settings
dialogs the OS showed 0
Tickets
request() at launch → …
Step 1 / 16 · step by step
unaskedthe OS's record
deniedcheck() says
0dialogs the OS showed

The picture: a big phone standing in the city shows the ticket app's screens, the OS's own dialog and the Settings app, as the person sees them. Beside it is the OS's hall: the board over its door is the record the OS keeps for this app (grey never asked, amber denied, red blocked, green granted), and the Settings office is up the street. request() and check() are lights from the phone to the desk and back. A model of the rules iOS and Android document, not a recording of a real phone.

Step 4 · Every option at once, on one clock

Compare them all: Permissions on a phone

The same app asks for the camera three times, and the same person answers the same on every phone: no, no, then yes (never ticking Don't ask again). Count how many times each system still shows its dialog.

asked 0/3
iOSasks oncedialogs shown 0 now unasked

Use it when One ask per permission, so the first one matters most: ask right after they tap the feature, with a usage description that makes sense

Skip it when Asking at launch, or many permissions in a row: one Don't Allow means a trip to Settings

A model of the rules each OS documents, not a run on real phones. Press any tile to see it large above, with when it fits.

Four answers, one of them final

StatusMeansThe app does
grantedyes (limited: yes, with less, like some photos)uses the feature
deniedno or never asked, and the OS may still show its dialogexplains, then asks when the person taps the feature
blockedno, and the OS won't show its dialog againoffers another way, and a button to Settings
unavailablethis device can't do it at allhides the feature

Ask when it's needed

Not at launch, and not five permissions in a row. Wait for the tap that needs it, say in one line what it's for, then let the OS ask. On iOS that first answer is the only one you get without the Settings app.

Android counts refusals

Since Android 11 a second "Don't allow" means the dialog won't come back; on Android 6 to 10 that took a ticked "Don't ask again". And check() on Android answers denied even then: only request() finds out the dialog is gone.

In real code

CameraScan.tsx
// Ask for the camera only when someone taps Scan, say why first, and keep the app useful when the answer is no.
// react-native-permissions gives iOS and Android the same statuses: granted, denied (may ask again),
// blocked (the OS won't show its dialog any more), limited, unavailable.
import { useCallback, useEffect, useState } from "react";
import { AppState, Platform, Pressable, Text, View } from "react-native";
import { PERMISSIONS, RESULTS, check, openSettings, request, type PermissionStatus } from "react-native-permissions";

const CAMERA = Platform.OS === "ios" ? PERMISSIONS.IOS.CAMERA : PERMISSIONS.ANDROID.CAMERA;

export function CameraScan({ onScan, onTypeCode }: { onScan: () => void; onTypeCode: () => void }) {
  const [status, setStatus] = useState<PermissionStatus | null>(null);
  const [explain, setExplain] = useState(false);

  // check() never shows a dialog. On Android it never says blocked either: only request() finds that out.
  const refresh = useCallback(() => { void check(CAMERA).then(setStatus); }, []);
  useEffect(() => {
    refresh();
    // Back from the Settings app: look again, the person may have switched the camera on there.
    const sub = AppState.addEventListener("change", (s) => { if (s === "active") refresh(); });
    return () => sub.remove();
  }, [refresh]);

  const ask = async () => {
    setExplain(false);
    const next = await request(CAMERA); // the OS dialog, if it may still show one
    setStatus(next);
    if (next === RESULTS.GRANTED || next === RESULTS.LIMITED) onScan();
  };

  const scan = () => {
    if (status === RESULTS.GRANTED || status === RESULTS.LIMITED) onScan();
    else if (status === RESULTS.BLOCKED) void openSettings();
    else setExplain(true); // one line on why, before the OS asks
  };

  return (
    <View style={{ gap: 12, padding: 16 }}>
      {explain ? (
        <View accessibilityRole="alert">
          <Text>We use the camera only to scan your ticket, and only while you scan.</Text>
          <Pressable accessibilityRole="button" onPress={() => void ask()}><Text>Continue</Text></Pressable>
          <Pressable accessibilityRole="button" onPress={() => setExplain(false)}><Text>Not now</Text></Pressable>
        </View>
      ) : null}
      {status === RESULTS.BLOCKED ? <Text>The camera is off for this app. Turn it on in Settings, or type the code.</Text> : null}
      {status === RESULTS.UNAVAILABLE ? <Text>This device has no camera we can use. Type the code instead.</Text> : null}
      {status !== RESULTS.UNAVAILABLE ? (
        <Pressable accessibilityRole="button" onPress={scan}>
          <Text>{status === RESULTS.BLOCKED ? "Open Settings" : "Scan with camera"}</Text>
        </Pressable>
      ) : null}
      {/* Never a dead end: the job can be done without the camera. */}
      <Pressable accessibilityRole="button" onPress={onTypeCode}><Text>Type the code</Text></Pressable>
    </View>
  );
}
Run: tsc against each library's own published types (react-native and the libraries this file imports); type-checked only, never run on a phoneIt printed: tsc 6.0.3 (strict): no errors against react-native 0.88.1, react-native-permissions 5.7.0 (type-checked only)

The screen with react-native-permissions: check() on mount and again when the app comes back from Settings, one line of why before request(), Settings for blocked, and a way to finish without the camera. Type-checked with tsc against the types react-native 0.88 and react-native-permissions publish; no phone ran it. On iOS the library also needs the camera listed in setup_permissions in your Podfile.

Common questions

When should an app ask for a permission?

When they tap the thing that needs it: ask for the camera when they tap Scan. Give the reason on the app's own screen first, then call request(). At launch nobody knows yet what it's for.

Read: ask when it's needed

What's the difference between denied and blocked?

Denied means no for now, and the OS may still show its dialog. Blocked means it won't: request() answers blocked at once, and only the person, in Settings, can change it.

Table: four answers

Can I ask again on iOS?

No. iOS asks once per permission per install. After a no, request() shows no dialog however often you call it; all the app can do is explain and take them to Settings with openSettings().

How many times can I ask on Android?

On Android 11 and later, after the second no the dialog doesn't come back. On Android 6 to 10 it stops only when they tick Don't ask again. Spend the ask you have left on explaining first; don't keep asking.

Why does check() say denied on Android when the dialog won't come back?

Android doesn't tell you through check() that the dialog is gone. react-native-permissions says it outright: on Android check() never answers blocked. Call request() and look at the answer.

Read: Android counts refusals

What should the app do after a no?

Keep working another way, like typing the code instead of scanning, and say plainly that it's off. If it's blocked, offer a button to Settings, and listen to AppState: when the app is active again, check() once more.

What goes in Info.plist and AndroidManifest.xml?

iOS needs a usage description such as NSCameraUsageDescription; without it the app is closed when it touches the camera. Android needs the CAMERA uses-permission declared, or there's no dialog at runtime.

Next lesson

Safe areasLevel: Basic

The app asks at the right moment now; next, the insets that keep its screens clear of the notch, the Dynamic Island and the home bar.