RxSwift bindings for Permissions API in iOS.

Overview

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.

Comments
  • Small changes

    Small changes

    Hi Luke,

    I never would have dreamt that a lib would be created on top on Permission 😍😍 Thank you so much!!!

    I tried to give back a bit with this PR ;)

    opened by delba 5
  • Code style is not perfect

    Code style is not perfect

    I think this will be better.

    Permission.rx.contacts
        .subscribeNext { status in
            print("Status: \(status)")
        }
        .addDisposableTo(disposeBag)
    
    opened by roshanman 4
  • Observable create pattern for async calls

    Observable create pattern for async calls

    Your code seemed to be over engineered in regards to how observables work.

    I refactored it into a Observable.create pattern for async usage.

    I only noticed this because when subscribing to the event, it would only trigger once per permission instance, making flatMap usage quite limited.

    e.g. usage:

    locationButton.rx_tap
          .flatMap {
            return Permission.LocationAlways.rx_permission
          }.subscribeNext { status in
            print(status)
          }.addDisposableTo(rx_disposeBag)
    
    opened by ivanbruel 3
  • 疑似框架内报错:java.util.List.iterator()' on a null object reference

    疑似框架内报错:java.util.List.iterator()' on a null object reference

    这是我在友盟看到的报错: Caused by: e.b.f: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference at e.d.d.c$a.a(InternalObservableUtils.java:386) at e.d.d.c$a.a(InternalObservableUtils.java:383) at e.d.d.a.a(ActionSubscriber.java:44) at e.e.b.b(SafeSubscriber.java:157) at e.e.b.a(SafeSubscriber.java:120) at e.b.b.a(Exceptions.java:204) at e.e.b.a(SafeSubscriber.java:144) at e.d.a.r$e.a(OperatorMerge.java:505) at e.d.a.r$e.b(OperatorMerge.java:463) at e.d.a.r$e.a(OperatorMerge.java:246) at e.d.a.r$e.a(OperatorMerge.java:147) at e.d.a.q$a.a(OperatorMap.java:74) at e.d.a.n$a.a(OperatorBufferWithSize.java:114) at e.d.a.r$e.a(OperatorMerge.java:393) at e.d.a.r$e.a(OperatorMerge.java:355) at e.d.a.r$c.a(OperatorMerge.java:840) at e.e.c.a(SerializedObserver.java:95) at e.e.d.a(SerializedSubscriber.java:95) at e.d.a.d$c.b(OnSubscribeConcatMap.java:182) at e.d.a.d$b.a(OnSubscribeConcatMap.java:335) at e.h.d$b.a(SubjectSubscriptionManager.java:225) at e.h.b.a(PublishSubject.java:114) at com.tbruyelle.rxpermissions.RxPermissionsFragment.a(RxPermissionsFragment.java:66) at com.tbruyelle.rxpermissions.RxPermissionsFragment.onRequestPermissionsResult(RxPermissionsFragment.java:51) at android.app.Activity.dispatchRequestPermissionsResultToFragment(Activity.java:6733) at android.app.Activity.dispatchActivityResult(Activity.java:6605) at android.app.ActivityThread.deliverResults(ActivityThread.java:3733) ... 9 more

    说是:RxPermissionsFragment第66行。具体是这一行: subject.onNext(new Permission(permissions[i], granted, shouldShowRequestPermissionRationale[i]));

    版本是最新的0.9.4。 这是我的猜测,希望作者可以看看,毕竟是crash级别的bug! Thanks!

    opened by techwnn 2
  • 1.0.0-beta.2 not found

    1.0.0-beta.2 not found

    Hi, I tried to install 1.0.0-beta.2 via Cocoapods but after I update repo source it still told me 1.0.0-beta.2 not exists.

    The latest version shows 1.0.0-beta.1 in cocoapods.org.

    If you forget to upload to cocoapods, I just writing to remind you of that, but if that is my pod's problem, please tell me and I will try to fix it.

    opened by Calvin-Huang 2
  • Will never execute twice

    Will never execute twice

    The subscribeNext closure will not execute twice at application's life cycle. If this code is written in a UIViewController when second time appeared the label.text will be empty.

    Permission
                .LocationAlways
                .rx_permission
                .subscribeNext { status in
                    print(status)
                    self.label.text = "Status: \(status)"
                }
                .addDisposableTo(disposeBag)
    
    opened by xspyhack 2
  • fix a scoping issue caused by RxSwift 3.0

    fix a scoping issue caused by RxSwift 3.0

    Sorry about this @sunshinejr! Updating to 3.0.0 moved Reactive from RxCocoa to RxSwift, so it broke this.

    I should have checked to make sure RxPermission compiled with the new RxSwift before submitting a PR 😅

    opened by AndrewSB 1
  • Swift 3.0 Support

    Swift 3.0 Support

    Added Swift 3.0 Support.

    As dependencies have not been released yet, to use the Swift 3.0 version you need to set this in your Podfiles:

    pod 'RxPermission', :git => 'https://github.com/ivanbruel/RxPermission'
    pod 'Permission', :git => 'https://github.com/delba/Permission', :branch => 'swift-3.0'
    pod 'RxSwift', :git => 'https://github.com/ReactiveX/RxSwift'
    
    opened by ivanbruel 1
Owner
Luke
Luke
Cocoa framework and Obj-C dynamism bindings for ReactiveSwift.

Reactive extensions to Cocoa frameworks, built on top of ReactiveSwift. ⚠️ Looking for the Objective-C API? ?? Migrating from RAC 4.x? ?? Release Road

null 20k Jan 8, 2023
Lightweight observations and bindings in Swift

What is Hanson? Hanson is a simple, lightweight library to observe and bind values in Swift. It's been developed to support the MVVM architecture in o

Blendle 526 Oct 18, 2022
Animated RxCocoa bindings

RxAnimated - animated bindings RxAnimated provides animation interface to RxCocoa's bindings. It comes with few predefined animation bindings, and pro

RxSwift Community 687 Oct 26, 2022
Simple, lightweight swift bindings

Bindy Just a simple bindings. Installation Add pod 'Bindy' to your podfile, and run pod install SPM is supported too. Usage For now, Bindy has a coupl

Maxim Kotliar 25 Dec 12, 2022
RxAlamoRecord combines the power of the AlamoRecord and RxSwift libraries to create a networking layer that makes interacting with API's easier than ever reactively.

Written in Swift 5 RxAlamoRecord combines the power of the AlamoRecord and RxSwift libraries to create a networking layer that makes interacting with

Dalton Hinterscher 9 Aug 7, 2020
iOS & OSX Bluetooth library for RxSwift

RxBluetoothKit is a Bluetooth library that makes interaction with BLE devices much more pleasant. It's backed by RxSwift and CoreBluetooth and it prov

Polidea 1.3k Dec 16, 2022
Super Simple Pager with RxSwift extension

SSPager Super Simple Pager Example To run the example project, clone the repo, and run pod install from the SSPagerExample directory first. Installati

9oya 4 Jul 10, 2022
RxSwift extentions for Swift optionals and "Occupiable" types

RxOptional RxSwift extentions for Swift optionals and "Occupiable" types. Usage All operators are available on Driver as well unless otherwise marked.

Thane Gill 8 Jun 28, 2020
RxSwift wrapper around the elegant HTTP networking in Swift Alamofire

RxAlamofire RxAlamofire is a RxSwift wrapper around the elegant HTTP networking in Swift Alamofire. Getting Started Wrapping RxSwift around Alamofire

RxSwift Community 1.6k Jan 3, 2023
RxSwift extension for RealmSwift's types

RxRealm This library is a thin wrapper around RealmSwift ( Realm Docs ). Table of contents: Observing object collections Observing a single object Wri

RxSwift Community 1.1k Jan 6, 2023
A testable RxSwift wrapper around MultipeerConnectivity

A testable RxSwift wrapper around MultipeerConnectivity RxMultipeer is a RxSwift wrapper for MultipeerConnectivity. Using the adapter pattern, we can

RxSwift Community 69 Jul 5, 2022
RxSwift reactive wrapper for view gestures

RxGesture Usage To run the example project, clone the repo, in the Example folder open RxGesture.xcworkspace. You might need to run pod install from t

RxSwift Community 1.3k Dec 30, 2022
Handy RxSwift extensions on NSObject, including rx.disposeBag.

NSObject+Rx If you're using RxSwift, you've probably encountered the following code more than a few times. class MyObject: Whatever { let disposeBag

RxSwift Community 625 Dec 12, 2022
RxSwift extensions for Core Data

RxCoreData Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Xcode 9.0 Swift 4.0

RxSwift Community 164 Oct 14, 2022
🤖 RxSwift + State Machine, inspired by Redux and Elm.

RxAutomaton RxSwift port of ReactiveAutomaton (State Machine). Terminology Whenever the word "signal" or "(signal) producer" appears (derived from Rea

Yasuhiro Inami 719 Nov 19, 2022
STDevRxExt contains some extension functions for RxSwift and RxCocoa which makes our live easy.

STDevRxExt Example To run the Example.playground, clone the repo, and run pod install from the Example directory first. Requirements iOS 9.0+ tvOS 9.0

STDev 6 Mar 26, 2021
Support Combine Assign subscriber in RxSwift.

RxAssign Support Combine Assign subscriber in RxSwift. Assign uses a KeyPath which is really nice and useful. ** RxAssign extends Driver and Signal in

Won Heo 3 Dec 7, 2021
This is the demo of MVVM-C structure with dependency injection using RxSwift.

MVVMC-Demo Demo defination This is the demo project, I have integrated two APIs for MovieDB APIS (https://www.themoviedb.org/). One for the listing of

Anshul Shah 61 Dec 6, 2022
A configurable api client based on Alamofire4 and RxSwift4 for iOS

SimpleApiClient A configurable api client based on Alamofire4 and RxSwift4 for iOS Requirements iOS 8.0+ Swift 4 Table of Contents Basic Usage Unwrap

Jay 67 Dec 7, 2020