iOS 用戶權限處理:PermissionScope
PermissionScope 是 Swift 框架,是智能 iOS 用戶權限 UI 和統一 API,可以智能的處理用戶權限請求。
代碼示例:
class ViewController: UIViewController {
let pscope = PermissionScope()
override func viewDidLoad() {
super.viewDidLoad()
pscope.addPermission(PermissionConfig(type: .Contacts, demands: .Required, message: "We use this to steal\r\nyour friends"))
pscope.addPermission(PermissionConfig(type: .Notifications, demands: .Optional, message: "We use this to send you\r\nspam and love notes", notificationCategories: .None))
pscope.addPermission(PermissionConfig(type: .LocationInUse, demands: .Required, message: "We use this to track\r\nwhere you live"))
pscope.show()
}
@IBAction func doAThing() {
pscope.show(authChange: { (finished, results) -> Void in
println("got results \(results)")
}, cancelled: { (results) -> Void in
println("thing was cancelled")
})
}
} 本文由用戶 ynnc 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!