Help in request access to device services like noitifcations, location and camera.
- iOS 10.0
- Xcode 11
- Swift 5.1
Copy the Permission
folder to your project.
Add import Permission
to your source code, unless you copied the source code.
let configration = Permission.Configuration()
let permission = Permission(presenter: self, type: .camera, configuration: configration)
permission.request { [weak self] status in
print(status) // Check the received status
}
public enum PermissionStatus {
/// User authories access
///
case authorized
/// User denied permission
///
case denied
/// Unable to find the required type
///
case disabled
/// Unable to determine current state
///
case notDetermined
}
public enum PermissionType {
/// Notifications
///
case notification(options: UNAuthorizationOptions = [])
/// Camera, Used for photo and video
///
case camera
/// Location. We can request even always or when in use
///
case location(locationType: LocationPermissionType)
}
public enum LocationPermissionType {
/// Location services regardless of whether the app is in use.
///
case always
/// Location services while the app is in use.
///
case whenInUse
}
This repo was created for demo purposes. If you find an issue, open a ticket. Pull requests are warmly welcome as well.