iOS 8: pod 'PermissionScope', '~> 0.7'
iOS 7: 从源文件中获取
在AppDelegate
的applicationDidBecomeActive
方法中添加
func applicationDidBecomeActive(application: UIApplication) {
if let root = self.window?.rootViewController {
AppPermissionsViewController.restoreControllerIfNeeded(root)
}
}
如果iOS 7中添加
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
...
self.window?.rootViewController?.modalPresentationStyle = UIModalPresentationStyle.CurrentContext;
return true
}
AppPermissionsViewController.present(self, types: [.Calendars, .Camera, .Contacts]) { success in
if success {
...
}
在info.plist
中添加行NSLocationAlwaysUsageDescription
和NSLocationWhenInUseUsageDescription
以在对话框消息中进行描述(必需)
在info.plist
中添加行NSBluetoothPeripheralUsageDescription
并在能力
部分启用background-modes
并选中Acts as a Bluetooth LE accessory
复选框(必需)