项目作者: sunshinejr

项目描述 :
RxSwift bindings for Permissions API in iOS.
高级语言: Swift
项目地址: git://github.com/sunshinejr/RxPermission.git
创建时间: 2016-04-16T19:45:38Z
项目社区:https://github.com/sunshinejr/RxPermission

开源协议:MIT License

下载


RxPermission

CocoaPods
Swift 3.0.x
License
Platform

RxSwift bindings for Permission API that helps you with Permissions in iOS.

Installation

RxPermission is available through CocoaPods. I can’t
guarantee it is working correctly on Carthage, so if you want to help I’m happy
to introduce it with your PR.

RxPermission should work with every Swift release >= 2.2, for detailed
instructions check info below.

Swift 3.0

If you want to use RxPermission with Swift 3.0 you have to specify which
Permission you want to install/use because of new Apple policy about permission.
For example if you want to access the Camera and the Notifications you define the following:

  1. pod 'RxPermission/Camera'
  2. pod 'RxPermission/Notifications'

Available specs:

  1. pod 'RxPermission/AddressBook'
  2. pod 'RxPermission/Bluetooth'
  3. pod 'RxPermission/Camera'
  4. pod 'RxPermission/Contacts'
  5. pod 'RxPermission/Events'
  6. pod 'RxPermission/Location'
  7. pod 'RxPermission/MediaLibrary'
  8. pod 'RxPermission/Microphone'
  9. pod 'RxPermission/Motion'
  10. pod 'RxPermission/Notifications'
  11. pod 'RxPermission/Photos'
  12. pod 'RxPermission/Reminders'
  13. pod 'RxPermission/Siri'
  14. pod 'RxPermission/SpeechRecognizer'

Below Swift 3.0

To install it, simply add the following line to your Podfile:

  1. pod "RxPermission", "~> 0.2"

You need to also take care of Info.plist messages because otherwise Apple won’t
accept the app in App Store.

Usage

RxPermission makes a rx.permission Observable that you can subscribe in order to receive signals.

Sample code

  1. Permission
  2. .contacts
  3. .rx.permission
  4. .subscribe(onNext: { status in
  5. print("Status: \(status)")
  6. })
  7. .addDisposableTo(disposeBag)

Available permissions:

  1. public enum PermissionType {
  2. case addressBook
  3. case bluetooth
  4. case camera
  5. case contacts
  6. case events
  7. case locationAlways
  8. case locationWhenInUse
  9. case mediaLibrary
  10. case microphone
  11. case motion
  12. case notifications
  13. case photos
  14. case reminders
  15. case siri
  16. case speechRecognizer
  17. }

Available statuses:

  1. public enum PermissionStatus {
  2. case authorized
  3. case denied
  4. case disabled
  5. case notDetermined
  6. }

For more info about permissions and statuses, please visit Permission’s README.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Author

Sunshinejr, thesunshinejr@gmail.com, @thesunshinejr

License

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