addPermissionDescription method

OperationResult addPermissionDescription(
  1. String permissionKey,
  2. String description
)

Adds a permission usage description to Info.plist.

This is a convenience method for adding iOS permission strings. It automatically appends "UsageDescription" to the key if not present.

Common Permission Keys

Key Purpose
NSCamera Camera access
NSPhotoLibrary Photo library access
NSLocationWhenInUse Location while app is in use
NSLocationAlways Background location access
NSMicrophone Microphone access
NSContacts Contacts access
NSCalendars Calendar access
NSFaceID Face ID biometric authentication

Parameters

  • permissionKey: The permission key (e.g., NSCamera or NSCameraUsageDescription)
  • description: The user-facing description shown in the permission dialog

Returns

  • Success if the permission was added or already exists
  • Failure if the plist could not be found or modified

Example

final manager = IosManager('/path/to/project');

// Both of these produce the same result:
manager.addPermissionDescription('NSCamera', 'We need camera for photos');
manager.addPermissionDescription('NSCameraUsageDescription', 'We need camera for photos');

Implementation

OperationResult addPermissionDescription(String permissionKey, String description) {
  final normalizedKey = permissionKey.endsWith('UsageDescription')
      ? permissionKey
      : '${permissionKey}UsageDescription';

  return addPlistKey(normalizedKey, description);
}