Rxswift: How can I add support to PHPhotoLibrary with RxSwift?

Created on 12 Nov 2016  路  2Comments  路  Source: ReactiveX/RxSwift

  • I want to add support to request authorization of PHPhotoLibrary with RxSwift.How to do it?
    like PHPhotoLibrary.rx.didAuthorization.subscribe(.....)
        PHPhotoLibrary.requestAuthorization { (systemStatus) in
            switch systemStatus {
            case .denied, .notDetermined, .restricted:
                complete(.fail)
            case .authorized:
                complete(.success)
            }
        }

Most helpful comment

@cleexiang there is also a really nice permissions library: https://github.com/sunshinejr/RxPermission that implements this for all the iOS permissions

All 2 comments

Hi @cleexiang ,

probably something like:

return Observable.create { (observer: AnyObserver<SystemStatusType>) in 
    PHPhotoLibrary.requestAuthorization { (systemStatus) in
            observer.on(.next(systemStatus))
            observer.on(.completed)           
        }

        return Disposables.create()
}

@cleexiang there is also a really nice permissions library: https://github.com/sunshinejr/RxPermission that implements this for all the iOS permissions

Was this page helpful?
0 / 5 - 0 ratings