Permission API Reference

Named permission constants, platform availability, native mappings, restrictions, and official Apple and Android documentation.

Use the named Permission, IosPermission, and AndroidPermission constants with the task’s ansight.permissions APIs. They are frozen JavaScript exports with readonly string literal types, so they work with native TypeScript execution. The generated runtime module and declarations include hover docs on every constant.

Usage

Run ansight workspace init . to install ansight/tasks/ansight-task.js and its declarations. Existing support files are preserved by default; --force refreshes canonical files after upgrading the CLI. Nested tasks adjust the relative import path, for example ../ansight-task.js.

import { Permission, IosPermission, AndroidPermission } from "./ansight-task.js";
import type { TaskInvocation } from "./ansight-task.d.ts";

export default async function run({ ansight, expect }: TaskInvocation) {
  await ansight.permissions.grant({ permission: Permission.Microphone });
  const access = await ansight.permissions.query({ permission: Permission.Microphone });
  expect(access.status, { id: "microphone-granted" }).toBe("granted");
  await ansight.permissions.revoke({ permission: Permission.Microphone });

  // Put native calls in tasks for the corresponding platform.
  await ansight.permissions.ios.reset({ permission: IosPermission.Photos });
  await ansight.permissions.android.grant({ permission: AndroidPermission.Camera });
}

Permission, IosPermission, and AndroidPermission can also be used as value types. AppPermission aliases the shared union, and CommonAndroidPermission is the union of the Android constants. AndroidPermission also accepts other fully qualified identifiers, such as "com.example.permission.CUSTOM". Literal strings and the earlier lowercase .names catalogs remain supported.

Platform and operation availability

APIDevicesOperations
ansight.permissionsiOS Simulator; Android emulator or authorized physical device, subject to each row belowgrant, revoke, query using resource approximations
ansight.permissions.iosiOS Simulator only; physical iOS and Android unsupportedgrant, revoke, query, reset using exact simctl services
ansight.permissions.androidAndroid emulator or authorized physical device; iOS unsupportedgrant, revoke, query using exact manifest identifiers

All operations use the task’s enforced app and session in SDK or device mode; no hostTools declaration or target overrides are needed. Await native calls serially. The Android API levels below describe when a manifest identifier was introduced. Runtime grant/revoke require Android’s runtime-permission mechanism (API 23+), a declared permission managed at runtime, and native policy permitting the change. A constant’s existence does not guarantee effective resource access.

For iOS, mutations require the named service in the installed simctl privacy service list. Xcode 11.4 introduced simctl privacy control. Queries read Simulator TCC or location authorization stores; unrecognized or unreadable state is unknown. The camera service can be queried even when mutations are unavailable. iOS notification control has no backend in this provider. Hardware, global device settings, app capabilities, roles, and usage descriptions are distinct from the authorization state controlled here.

Shared permissions

Each constant maps to the native permissions listed in its row. Android manifest identifiers use the full android.permission. prefix in the linked labels. Calendar, foreground location, and visual media use the subset the app declares. Results expose the exact subset in nativePermissions.

Constant and valueAvailability and behavioriOS mapping and docsAndroid mapping and docs
Permission.Camera ("camera")Android emulators and authorized physical devices; iOS Simulator queries TCC. iOS mutations require camera in installed simctl privacy services.cameraandroid.permission.CAMERA
Permission.Microphone ("microphone")iOS Simulator; Android emulators and authorized physical devices.microphoneandroid.permission.RECORD_AUDIO
Permission.Contacts ("contacts")iOS Simulator; Android emulators and authorized physical devices.contactsandroid.permission.READ_CONTACTS
Permission.Calendar ("calendar")iOS Simulator; Android emulators and authorized physical devices. EventKit full/write-only access is not separately modeled.calendarandroid.permission.READ_CALENDAR / android.permission.WRITE_CALENDAR
Permission.Photos ("photos")iOS Simulator; Android emulators and authorized physical devices. Android 14+ selected access is queried and revoked, but grant does not select particular media.photosandroid.permission.READ_MEDIA_IMAGES / android.permission.READ_MEDIA_VIDEO on API 33+ with target SDK 33+; android.permission.READ_EXTERNAL_STORAGE otherwise
Permission.Location ("location")iOS Simulator; Android emulators and authorized physical devices.locationandroid.permission.ACCESS_COARSE_LOCATION / android.permission.ACCESS_FINE_LOCATION
Permission.LocationAlways ("locationAlways")iOS Simulator; Android emulators and authorized physical devices. Android grants declared foreground dependencies first. On API 29+, revoke removes background access only; iOS revoke denies location entirely.location-alwaysandroid.permission.ACCESS_BACKGROUND_LOCATION on API 29+; android.permission.ACCESS_COARSE_LOCATION / android.permission.ACCESS_FINE_LOCATION on older Android
Permission.MediaLibrary ("mediaLibrary")iOS Simulator; Android emulators and authorized physical devices.media-libraryandroid.permission.READ_MEDIA_AUDIO on API 33+ with target SDK 33+; android.permission.READ_EXTERNAL_STORAGE otherwise
Permission.Motion ("motion")iOS Simulator; Android API 29+ on emulators and authorized physical devices. Unsupported on older Android.motionandroid.permission.ACTIVITY_RECOGNITION
Permission.Notifications ("notifications")Android API 33+ on emulators and authorized physical devices. Unsupported on iOS and older Android.Unsupported; notification authorization docsandroid.permission.POST_NOTIFICATIONS

Background location grants the declared Android foreground dependencies first; on API 29+, shared revocation removes only background access. iOS location-always revocation denies all location access. Android 14+ selected photo access can produce limited and is included in shared Photos revocation; grants do not choose which photos or contacts a user shares.

Native iOS permissions

Every row is iOS Simulator only, with no Android native mapping or physical iOS support. Grant/revoke/reset depend on the installed simctl service list. Use shared Permission constants when you want an Android resource equivalent.

ConstantNative simctl serviceAvailability and behaviorOfficial platform docs
IosPermission.CameracameraiOS Simulator; Queries TCC. Mutations require camera in installed simctl services; the provider does not supply camera hardware.Apple authorization docs
IosPermission.MicrophonemicrophoneiOS Simulator; Queries read the Simulator authorization store; unreadable state is unknown.Apple authorization docs
IosPermission.ContactscontactsiOS Simulator; Queries read the Simulator authorization store; unreadable state is unknown.Apple authorization docs
IosPermission.ContactsLimitedcontacts-limitediOS Simulator; Requires a Simulator runtime and simctl service with limited-contact support. Does not choose specific contacts.Apple authorization docs
IosPermission.CalendarcalendariOS Simulator; Controls the simctl calendar service; EventKit full/write-only access is not separately modeled.Apple authorization docs
IosPermission.PhotosphotosiOS Simulator; Controls photo-library authorization; limited user selections can remain limited.Apple authorization docs
IosPermission.PhotosAddphotos-addiOS Simulator; Controls add-only photo authorization; grants no photo-library read access.Apple authorization docs
IosPermission.LocationlocationiOS Simulator; When-in-use location. Authorization is distinct from simulated device coordinates.Apple authorization docs
IosPermission.LocationAlwayslocation-alwaysiOS Simulator; Always location. Revoking this simctl service denies all location access.Apple authorization docs
IosPermission.MediaLibrarymedia-libraryiOS Simulator; Controls media-library authorization; does not populate the Simulator with music.Apple authorization docs
IosPermission.MotionmotioniOS Simulator; Authorization is distinct from hardware or motion-data availability.Apple authorization docs
IosPermission.RemindersremindersiOS Simulator; Queries read the Simulator authorization store; unreadable state is unknown.Apple authorization docs
IosPermission.SirisiriiOS Simulator; Controls SiriKit authorization; Siri capability and app configuration are still required.Apple authorization docs

reset clears a native authorization decision so the next in-app request can prompt again. Simulator authorization does not supply camera hardware, motion data, media-library content, or Siri behavior.

Native Android permissions

Every row is Android only, on emulators or authorized physical devices. There is no native iOS mapping. The app must declare the identifier and native pm must allow the operation for the active Android user. Shared names provide cross-platform resource approximations where available.

ConstantNative identifier and official docsIdentifier availabilityRestrictions and behavior
AndroidPermission.Cameraandroid.permission.CAMERAAndroid API 1+Device services and app roles can further constrain effective access.
AndroidPermission.RecordAudioandroid.permission.RECORD_AUDIOAndroid API 1+Device services and app roles can further constrain effective access.
AndroidPermission.ReadContactsandroid.permission.READ_CONTACTSAndroid API 1+Device services and app roles can further constrain effective access.
AndroidPermission.WriteContactsandroid.permission.WRITE_CONTACTSAndroid API 1+Device services and app roles can further constrain effective access.
AndroidPermission.GetAccountsandroid.permission.GET_ACCOUNTSAndroid API 1+Does not sign in to accounts or grant account-provider access; signature and account-visibility rules still apply.
AndroidPermission.ReadCalendarandroid.permission.READ_CALENDARAndroid API 1+Device services and app roles can further constrain effective access.
AndroidPermission.WriteCalendarandroid.permission.WRITE_CALENDARAndroid API 1+Device services and app roles can further constrain effective access.
AndroidPermission.AccessCoarseLocationandroid.permission.ACCESS_COARSE_LOCATIONAndroid API 1+Device services and app roles can further constrain effective access.
AndroidPermission.AccessFineLocationandroid.permission.ACCESS_FINE_LOCATIONAndroid API 1+Approximate user choices can limit effective precision; authorization is distinct from device location settings.
AndroidPermission.AccessBackgroundLocationandroid.permission.ACCESS_BACKGROUND_LOCATIONAndroid API 29+Installer allowlisting is required; pm does not bypass native restrictions. Requires declared and granted foreground coarse/fine location. Native calls do not automatically grant dependencies.
AndroidPermission.ReadMediaImagesandroid.permission.READ_MEDIA_IMAGESAndroid API 33+Use for apps targeting API 33+; older targets use READ_EXTERNAL_STORAGE.
AndroidPermission.ReadMediaVideoandroid.permission.READ_MEDIA_VIDEOAndroid API 33+Use for apps targeting API 33+; older targets use READ_EXTERNAL_STORAGE.
AndroidPermission.ReadMediaAudioandroid.permission.READ_MEDIA_AUDIOAndroid API 33+Use for apps targeting API 33+; older targets use READ_EXTERNAL_STORAGE.
AndroidPermission.ReadMediaVisualUserSelectedandroid.permission.READ_MEDIA_VISUAL_USER_SELECTEDAndroid API 34+Does not choose particular media. Use with declared READ_MEDIA_IMAGES/READ_MEDIA_VIDEO as appropriate; shared Photos revoke also clears this permission.
AndroidPermission.ReadExternalStorageandroid.permission.READ_EXTERNAL_STORAGEAndroid API 16+Legacy storage access is constrained by OS, target SDK, scoped storage, and installer policy. Use granular media permissions for target SDK 33+.
AndroidPermission.WriteExternalStorageandroid.permission.WRITE_EXTERNAL_STORAGEAndroid API 4+Has no storage-access effect for apps targeting API 30+.
AndroidPermission.ActivityRecognitionandroid.permission.ACTIVITY_RECOGNITIONAndroid API 29+Device services and app roles can further constrain effective access.
AndroidPermission.BodySensorsandroid.permission.BODY_SENSORSAndroid API 20+Apps targeting API 36+ use granular android.permission.health identifiers for affected sensor APIs. Android 16 migration.
AndroidPermission.BodySensorsBackgroundandroid.permission.BODY_SENSORS_BACKGROUNDAndroid API 33+Installer allowlisting is required; pm does not bypass native restrictions. Requires BODY_SENSORS first. Apps targeting API 36+ use READ_HEALTH_DATA_IN_BACKGROUND for affected APIs. Android 16 migration.
AndroidPermission.PostNotificationsandroid.permission.POST_NOTIFICATIONSAndroid API 33+Device services and app roles can further constrain effective access.
AndroidPermission.BluetoothScanandroid.permission.BLUETOOTH_SCANAndroid API 31+Device services and app roles can further constrain effective access.
AndroidPermission.BluetoothConnectandroid.permission.BLUETOOTH_CONNECTAndroid API 31+Device services and app roles can further constrain effective access.
AndroidPermission.BluetoothAdvertiseandroid.permission.BLUETOOTH_ADVERTISEAndroid API 31+Device services and app roles can further constrain effective access.
AndroidPermission.NearbyWifiDevicesandroid.permission.NEARBY_WIFI_DEVICESAndroid API 33+Device services and app roles can further constrain effective access.
AndroidPermission.ReadPhoneStateandroid.permission.READ_PHONE_STATEAndroid API 1+Device services and app roles can further constrain effective access.
AndroidPermission.ReadPhoneNumbersandroid.permission.READ_PHONE_NUMBERSAndroid API 26+Device services and app roles can further constrain effective access.
AndroidPermission.CallPhoneandroid.permission.CALL_PHONEAndroid API 1+Device services and app roles can further constrain effective access.
AndroidPermission.AnswerPhoneCallsandroid.permission.ANSWER_PHONE_CALLSAndroid API 26+Device services and app roles can further constrain effective access.
AndroidPermission.ReadCallLogandroid.permission.READ_CALL_LOGAndroid API 16+Installer allowlisting is required; pm does not bypass native restrictions.
AndroidPermission.WriteCallLogandroid.permission.WRITE_CALL_LOGAndroid API 16+Installer allowlisting is required; pm does not bypass native restrictions.
AndroidPermission.SendSmsandroid.permission.SEND_SMSAndroid API 1+Installer allowlisting is required; pm does not bypass native restrictions.
AndroidPermission.ReadSmsandroid.permission.READ_SMSAndroid API 1+Installer allowlisting is required; pm does not bypass native restrictions.
AndroidPermission.ReceiveSmsandroid.permission.RECEIVE_SMSAndroid API 1+Installer allowlisting is required; pm does not bypass native restrictions.
AndroidPermission.ReceiveMmsandroid.permission.RECEIVE_MMSAndroid API 1+Installer allowlisting is required; pm does not bypass native restrictions.
AndroidPermission.ReceiveWapPushandroid.permission.RECEIVE_WAP_PUSHAndroid API 1+Installer allowlisting is required; pm does not bypass native restrictions.

Installer restrictions, account visibility, call/SMS roles, scoped storage, and other native policy are enforced by Android; a pm grant is not a bypass. For custom or additional system permissions, pass a fully qualified identifier. Special access such as overlay, all-files access, and app roles requires other native APIs and is outside these permission methods.

Results and lifecycle

PermissionResult reports supported, isSuccess, status, backend, nativePermissions, and the enforced target identifiers. Status is granted, denied, notDetermined, limited, unsupported, or unknown. Mixed native states are limited. Unsupported queries return a result; unsupported mutations and failed native commands throw. Partial mutations retain individual observed states in the recorded result. A successful command reports subsequently observed state, which can be unknown if the store is unreadable.

Permission changes can terminate the app. Later calls retain the captured session target; use ansight.lifecycle.launch() when a task needs to relaunch it. Native grants can bypass the app’s usage-description checks, so test its actual prompt flow separately. See the task API for the complete host contract.