i'm using Fabric in order to add a "Sign In with Twitter" button in my app. Sign in process works fine, but I don't how (if it's possible) how to get the logged user's profile image.
Is there any property inside TWTRSession with this info (like userName and userID)? Looked for it but I didn't found anything?
[TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) {
// I get user data here...
// and need to get user Twitter's profile image
}];
Thanks
EDIT
Thanks to sak's answer, i figured out how to do it.
[TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) {
[[[Twitter sharedInstance] APIClient] loadUserWithID:session.userID completion:^(TWTRUser *user, NSError *error) {
NSLog(@"User image %@", user.profileImageURL);
}];
}];
For those who are getting this error :
Value of type 'Twitter' has no member 'APIClient'
This helped me,
let twitterClient = TWTRAPIClient(userID: userID)
twitterClient.loadUserWithID(userID) { (user:TWTRUser?, error:NSError?) in
print(user?.profileImageURL)
}
Try below code to get profile image -
Swift 3
let twitterClient = TWTRAPIClient(userID: session?.userID)
twitterClient.loadUser(withID: (session?.userID)!, completion: { (user, error) in
print(user!.profileImageURL)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With