GithubHelp home page GithubHelp logo

guangjun-chen / rxpermission Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chenhuafeng/rxpermission

0.0 2.0 0.0 62 KB

RxSwift bindings for Permissions API in iOS.

License: MIT License

Ruby 37.44% Swift 62.56%

rxpermission's Introduction

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:

pod 'RxPermission/Camera'
pod 'RxPermission/Notifications'

Available specs:

pod 'RxPermission/AddressBook'
pod 'RxPermission/Bluetooth'
pod 'RxPermission/Camera'
pod 'RxPermission/Contacts'
pod 'RxPermission/Events'
pod 'RxPermission/Location'
pod 'RxPermission/MediaLibrary'
pod 'RxPermission/Microphone'
pod 'RxPermission/Motion'
pod 'RxPermission/Notifications'
pod 'RxPermission/Photos'
pod 'RxPermission/Reminders'
pod 'RxPermission/Siri'
pod 'RxPermission/SpeechRecognizer'

Below Swift 3.0

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

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

Permission
    .contacts
    .rx.permission
    .subscribe(onNext: { status in
        print("Status: \(status)")
    })
    .addDisposableTo(disposeBag)

Available permissions:

public enum PermissionType {
    case addressBook
    case bluetooth
    case camera    
    case contacts
    case events
    case locationAlways
    case locationWhenInUse
    case mediaLibrary
    case microphone
    case motion
    case notifications
    case photos
    case reminders
    case siri
    case speechRecognizer
}

Available statuses:

public enum PermissionStatus {
    case authorized
    case denied
    case disabled
    case notDetermined
}

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, [email protected], @thesunshinejr

License

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

rxpermission's People

Contributors

sunshinejr avatar andrewsb avatar delba avatar chenhuafeng avatar ivanbruel avatar

Watchers

James Cloos avatar Guangjun Chen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.