Skip to content

Instantly share code, notes, and snippets.

@ramamilaneh
Created January 20, 2017 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramamilaneh/7baf592a8fcfa725ee98455330ffb5ee to your computer and use it in GitHub Desktop.
Save ramamilaneh/7baf592a8fcfa725ee98455330ffb5ee to your computer and use it in GitHub Desktop.
class func signInWithTwitter() {
Twitter.sharedInstance().logIn(withMethods: .webBased) { (session, error) in
if error != nil {
print(error?.localizedDescription)
}else{
if session != nil {
if let unwrappedSession = session {
let token = unwrappedSession.authToken
let secret = unwrappedSession.authTokenSecret
let credentials = FIRTwitterAuthProvider.credential(withToken: token, secret: secret)
FIRAuth.auth()?.signIn(with: credentials, completion: { (user, error) in
if let error = error {
print(error.localizedDescription)
let alert = UIAlertController(title: "error", message: "\(error.localizedDescription)", preferredStyle: .alert)
let okAction = UIAlertAction(title: "Ok", style: .default, handler: nil)
alert.addAction(okAction)
}else{
DispatchQueue.main.async {
NotificationCenter.default.post(name: .closeLoginVC, object: nil)
}
}
})
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment