Last active
January 2, 2018 15:03
-
-
Save RPallas92/d08129742ec98b5b0d09940beddec6fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func loginWithFacebook() -> AsyncResult<Context, String, GenericError> { | |
return AsyncResult.unfoldTT{ context, continuation in | |
let loginManager = LoginManager() | |
loginManager.logIn([ .publicProfile ], viewController: self) { loginResult in | |
switch loginResult { | |
case .Failed(let error): | |
continuation(Result.failure(error)) | |
case .Cancelled: | |
continuation(Result.failure(LoginCancelledError())) | |
case .Success(let grantedPermissions, let declinedPermissions, let accessToken): | |
continuation(Result.success(accessToken)) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment