[] (https://developer.apple.com/swift) [] (https://cocoapods.org/pods/AppPermissions)
iOS 8:
pod 'AppPermissions'
iOS 7: from Source Files
in applicationDidBecomeActive
in AppDelegate
add:
func applicationDidBecomeActive(application: UIApplication) {
if let root = self.window?.rootViewController {
AppPermissionsViewController.restoreControllerIfNeeded(root)
}
}
if iOS 7 add:
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 {
...
}
- PermissionType.AssetsLibrary
- .Bluetooth
- .Calendars
- .Camera
- .Contacts
- .Events
- .LocationAlways
- .LocationInUse
- .Microphone
- .Notifications
- .Photos
- .Reminders
add in info.plist
rows NSLocationAlwaysUsageDescription
and NSLocationWhenInUseUsageDescription
for description in dialog message (required)
add in info.plist
row NSBluetoothPeripheralUsageDescription
and enable background-modes
in the capabilities
section and check the Acts as a Bluetooth LE accessory
checkbox (required)