- Swift : 5.0
- RxSwift : '~> 6.5.0'
EzRxPermission is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'EzRxPermission'
PermissionType.UNUserNotificationCenter().isGranted
// MARK: - Single Permission
PermissionType.CLLocationManager.request
.subscribe(
onNext: { permission in
switch permission.result {
case .authorized:
print("Permission Authorized")
case .denied:
print("Permission Denied")
}
}
).disposed(by: disposBag)
// MARK: - Multiple Permission
var notificationOption: NotificationOption? = nil
if #available(iOS 10.0, *) {
notificationOption = NotificationOption(option: [.alert, .badge, .sound])
}
EzRxPermission.requestPermission(permissions: [.UNUserNotificationCenter(options: notificationOption), .CNContactStore])
.subscribe(
onNext: { permission in
switch permission.result {
case .authorized:
print("Permission Authorized")
case .denied:
print("Permission Denied")
}
}
).disposed(by: disposBag)
Permission | PermissionType | Option |
---|---|---|
AVAudioSession | Microphone | |
AVCaptureDevice | Camera | AVMediaType |
ATTrackingManager | AppTracking | |
CBPeripheralManager | Bluetooth | |
CLLocationManager | GPS | |
CNContactStore | Contacts | |
UNUserNotificationCenter | Notification | NotificationOption |
EKEventStore | Calendar | EKEntityType |
INPreferences | Siri | |
MPMediaLibrary | Media library | |
MotionManager | Motion | |
PHPhotoLibrary | Photo library | |
SFSpeechRecognizer | Speech recognition |
EzRxPermission is available under the MIT license. See the LICENSE file for more info.