Skip to content

Instantly share code, notes, and snippets.

@RPallas92
Last active January 2, 2018 15:03
Show Gist options
  • Save RPallas92/d08129742ec98b5b0d09940beddec6fc to your computer and use it in GitHub Desktop.
Save RPallas92/d08129742ec98b5b0d09940beddec6fc to your computer and use it in GitHub Desktop.
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