or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.mdpermission-management.mdreact-hooks.md
tile.json

permission-management.mddocs/

Permission Management

Core permission management functions providing cross-platform access to device permissions with unified API and deprecation warnings.

Capabilities

Get Permission Status

Checks current permission status without prompting the user. Returns current permission state for all specified permission types.

/**
 * Get current permission status without prompting user
 * @param types - Variable number of permission types to check
 * @returns Promise resolving to permission response with status and details
 * @deprecated Package deprecated - use individual Expo modules instead
 */
function getAsync(...types: PermissionType[]): Promise<PermissionResponse>;

Usage Examples:

import { getAsync, CAMERA, LOCATION_FOREGROUND } from "expo-permissions";

// Check single permission
const cameraStatus = await getAsync(CAMERA);
console.log("Camera granted:", cameraStatus.granted);

// Check multiple permissions
const multipleStatus = await getAsync(CAMERA, LOCATION_FOREGROUND);
console.log("All granted:", multipleStatus.granted);
console.log("Individual statuses:", multipleStatus.permissions);

Request Permissions

Requests permissions from the user, potentially showing system permission prompts. May trigger native permission dialogs on first request.

/**
 * Request permissions from user (may show system prompt)
 * @param types - Variable number of permission types to request
 * @returns Promise resolving to permission response with status and details
 * @deprecated Package deprecated - use individual Expo modules instead
 */
function askAsync(...types: PermissionType[]): Promise<PermissionResponse>;

Usage Examples:

import { askAsync, CAMERA, MEDIA_LIBRARY, LOCATION_FOREGROUND } from "expo-permissions";

// Request single permission
const cameraPermission = await askAsync(CAMERA);
if (cameraPermission.granted) {
  console.log("Camera access granted");
} else {
  console.log("Camera access denied");
}

// Request multiple permissions
const permissions = await askAsync(CAMERA, MEDIA_LIBRARY, LOCATION_FOREGROUND);
console.log("Overall status:", permissions.status);
console.log("Can ask again:", permissions.canAskAgain);

// Check individual permission details
Object.entries(permissions.permissions).forEach(([type, info]) => {
  console.log(`${type}: ${info.status}`);
  if (info.scope) {
    console.log(`  Scope: ${info.scope}`);
  }
  if (info.accessPrivileges) {
    console.log(`  Access: ${info.accessPrivileges}`);
  }
});

Permission Response Details

Both getAsync and askAsync return a PermissionResponse object with coalesced status and individual permission details:

interface PermissionResponse {
  /** Coalesced status of all requested permissions (UNDETERMINED > DENIED > GRANTED) */
  status: PermissionStatus;
  /** Earliest expiration time among all permissions, or 'never' */
  expires: PermissionExpiration;
  /** True only if ALL requested permissions are granted */
  granted: boolean;
  /** True only if ALL requested permissions can be asked again */
  canAskAgain: boolean;
  /** Map of individual permission details by permission type */
  permissions: PermissionMap;
}

Platform-Specific Behavior

iOS

  • Sequential Processing: Individual permission requests are handled sequentially rather than batched
  • Motion Permission: Always returns GRANTED status on non-web platforms without native request
  • Enhanced Errors: Unknown permissions include module mapping suggestions (e.g., "install expo-camera")
  • Media Library Privileges: Supports accessPrivileges field with values 'all', 'limited', or 'none'

Android

  • Batch Processing: Multiple permissions can be requested simultaneously in a single native call
  • Location Accuracy: Location permissions include android.accuracy field with 'fine', 'coarse', or 'none'
  • Motion Permission: Automatically granted on non-web platforms

Web

  • Limited Support: Reduced permission support compared to native platforms
  • Motion Handling: Motion permission requires explicit handling and user interaction

Error Handling

Common Errors:

// Unknown permission type
try {
  await getAsync('invalidPermission' as PermissionType);
} catch (error) {
  // E_PERMISSIONS_UNKNOWN with module suggestion
  console.log(error.message); // "Unknown permission type, please install expo-camera"
}

// Empty permission array
try {
  await askAsync();
} catch (error) {
  // "At least one permission type must be specified"
}

Permission Status Coalescing

When multiple permissions are requested, the library uses coalescing logic to determine overall status:

  • Status Priority: UNDETERMINED > DENIED > GRANTED (heaviest first)
  • Expiration: Returns earliest expiration time among all permissions
  • Granted: Returns true only if ALL permissions are granted
  • Can Ask Again: Returns true only if ALL permissions can be asked again
// Example: Mixed permission states
const result = await askAsync(CAMERA, LOCATION_FOREGROUND);
// If camera is GRANTED and location is DENIED:
// result.status = DENIED (heaviest status)
// result.granted = false (not all granted)
// result.canAskAgain = depends on both permissions