Skip to content

Latest commit

 

History

History
97 lines (74 loc) · 4.44 KB

README.md

File metadata and controls

97 lines (74 loc) · 4.44 KB

EzRxPermission

CI Status Version License Platform

Requirements

Version

  • Swift : 5.0
  • RxSwift : '~> 6.5.0'

Installation

EzRxPermission is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'EzRxPermission'

How to Use

Check permission granted

PermissionType.UNUserNotificationCenter().isGranted

Request permission (Single)

// 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)

Request permission (Multiple)

// 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)

Options

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

Author

yunjaena, jinbaejeong

License

EzRxPermission is available under the MIT license. See the LICENSE file for more info.