Created
January 20, 2017 22:25
-
-
Save ramamilaneh/7baf592a8fcfa725ee98455330ffb5ee 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
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