AuthorizeProtocol

public protocol AuthorizeProtocol

权限授权协议

  • 同步查询权限状态,必须实现。某些权限会阻塞当前线程,建议异步查询,如通知

    Declaration

    Swift

    func authorizeStatus() -> AuthorizeStatus
  • 异步执行权限授权,主线程回调,必须实现

    Declaration

    Swift

    func requestAuthorize(_ completion: (@MainActor @Sendable (AuthorizeStatus, Error?) -> Void)?)
  • authorizeStatus(_:) Default implementation

    异步查询权限状态,主线程回调,可选实现。某些权限建议异步查询,不会阻塞当前线程,如通知

    Default Implementation

    默认实现异步查询权限状态,主线程回调

    Declaration

    Swift

    func authorizeStatus(_ completion: (@MainActor @Sendable (AuthorizeStatus, Error?) -> Void)?)

Concurrency+Authorize

  • authorizeStatus() Extension method, asynchronous

    异步查询权限状态

    Declaration

    Swift

    public func authorizeStatus() async -> (status: AuthorizeStatus, error: Error?)
  • requestAuthorize() Extension method, asynchronous

    异步执行权限授权

    Declaration

    Swift

    public func requestAuthorize() async -> (status: AuthorizeStatus, error: Error?)