Giter VIP home page Giter VIP logo

permissiondirector's Introduction

说明

  • 请求从未询问的权限会弹出系统的权限窗口
  • 请求用户曾经拒绝的权限会展示弹窗提示用户,用户选择同意则跳入系统设置由用户手动打开此权限

效果

Cocoapods

podfile添加

pod 'PermissionDirector'

Carthage

cartfile添加

github "SoolyChristy/PermissionDirector"

Swift Package Manager

两种方式

  • package.swift添加
dependencies: [
    .package(url: "https://github.com/SoolyChristy/PermissionDirector.git", from: "0.0.4")
]
  • 在Xcode11中的PROJECT - Swift Packages 添加

使用

if !PermissionDirector.isAuthorized(for: .camera) {
  PermissionDirector.requestAuthorization(for: .camera) { (result) in
    if result == .authorized {
      print("camera permission has been authorized")
    }
  }
}

自定义弹窗

  • 自定义UIView实现PermissionAlertProtocol协议
public protocol PermissionAlertProtocol: class {
  /// 提供弹窗实例
  ///
  /// - Parameter type: 权限类型
  /// - Returns: 弹窗实例
  init(type: PermissionType)

  /// 展示弹窗
  func show()
  }
class PermissionHudView: UIView, PermissionAlertProtocol {
  required init(type: PermissionType) {
    super.init(frame: CGRect())
    // 你的实现
  }

  func show() {
    // 你的实现
  }
}
  • 更改弹窗类型
PermissionDirector.alertType = PermissionHudView.self

permissiondirector's People

Contributors

soolychristy avatar

Stargazers

 avatar  avatar ZST avatar  avatar xujiebing avatar yulong avatar  avatar john avatar 孙承波 avatar LnsooXD avatar Wallace avatar Orest Patlyka avatar  avatar lyhWork avatar Nicholas avatar  avatar 侠客老王 avatar  avatar Michael.Yang avatar  avatar  avatar 萨亚德夫 avatar tyz-coder avatar ChenZifeng avatar WiFi@憲有 avatar leiming avatar  avatar 商户老板 avatar  avatar Hemin Won avatar  avatar liujun avatar changsanjiang avatar run avatar

Watchers

GuoKai avatar James Cloos avatar Michael.Yang avatar  avatar

permissiondirector's Issues

whenInUse

Do not walk the callback method when the location click is allowed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.