Skip to content

Reactive extensions for Facebook Login and Graph Request


Notifications You must be signed in to change notification settings


Repository files navigation

Version License Platform


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

import FacebookLogin
import FacebookCore

class Example {
	let loginManager = LoginManager()

	func signIn() {
			loginManager.rx.logIn(with: [.publicProfile]).flatMap { [weak self] (loginResult) -> Observable<EmailResult> in
							guard let strongSelf = self else { return .just((nil, "Something went wrong")) }
							switch loginResult {
							case .cancelled: return .just((nil, "User cancelled the result"))
							case let .failed(error): return .just((nil, error.localizedDescription))
							// Extract the facebook login result here and chain it with your graph request
							case let .success(acceptedPermissions, declinedPermissions, accessToken): return strongSelf.fetchEmail()
					.subscribe(onNext: { email, error in
							if let `email` = email {
							} else if let `error` = error {
					.disposed(by: disposeBag)

	func fetchEmail() -> Observable<EmailResult> {
			let graphRequest  = GraphRequest(graphPath: "/me")
			return graphRequest.rx.getResponse().map { result in
					switch result {
					case let .success(response):
							guard let objectMap = response.dictionaryValue, let email = objectMap["email"] as? String else { return (nil, "Couldn't find email") }
							return (email, nil)
					case let .failed(error):
							return (nil, error.localizedDescription)


pod 'RxSwift'
pod 'FacebookCore'
pod 'FacebookLogin'


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

pod 'RxFacebook'


Sourav Chandra RxSwift Enthusiast


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