SystemPermissionAdapter

public protocol SystemPermissionAdapter : AnyObject

The interface for components that provide access to underlying system permissions.

  • Must return true only if this permission is available on the current runtime platform and device. This is used by the permission checker to avoid instantiating adapters that are not relevant, and to avoid access to APIs that are not available on all devices. Without this the permission checker has to have all the #if os(xxx) checks, which is invasive

    Declaration

    Swift

    static var isSupported: Bool { get }
  • Called to create all the adapters supported by this type of permission. This is called to enable adapters that have multiple variants to create all the appropriate objects for the current platform.

    Declaration

    Swift

    static func createAdapters(for permission: SystemPermissionConstraint) -> [SystemPermissionAdapter]
  • The permission this adapter can verify and authorise

    Declaration

    Swift

    var permission: SystemPermissionConstraint { get }
  • The current status of the permission

    Declaration

    Swift

    var status: SystemPermissionStatus { get }
  • The OS’s usage description key required for this permission. Used to sanity check that all required Info.plist are set

    Declaration

    Swift

    var usageDescriptionKey: String { get }
  • When called must ask the OS to ask the user to grant the permission

    Declaration

    Swift

    func requestAuthorisation(completion: @escaping (_ adapter: SystemPermissionAdapter, _ status: SystemPermissionStatus) -> Void)