iOS - TWTRShareEmailViewController - Receiving null for email address

ios
fabric

#1

Hi guys,

This is my first post on here so hopefully this works! :smile:

Basically I’ve integrated Twitter authentication on the Login Screen within my iOS App using the following code:

**[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession session, NSError error) {
if (session) {
NSLog(@“signed in as %@, User ID: %@”, [session userName],[session userID]);
[self performSelector:@selector(getTwitterEmail) withObject:nil afterDelay:1.0];
}
else {
NSLog(@“NO TWITTER SESSION - error: %@”, [error localizedDescription]);
}
}];

This works as expected, whereby I receive the users “userName” and “userID”. I then continue by requesting access to the users email address using the following code:

-(void)getTwitterEmail {
if ([[Twitter sharedInstance] session]) {
*TWTRShareEmailViewController shareEmailVC = [[TWTRShareEmailViewController alloc]initWithCompletion:^(NSString * _Nullable email, NSError * _Nullable error) {
NSLog(@“Email: %@, Error: %@”,email,error);
}];
[self presentViewController:shareEmailVC animated:YES completion:nil];
}
}

When the user selects allow access to the users email address, it should log the users email address, however the API returns null. I have contacted Twitter to ensure my App was whitelisted and they have confirmed that it is indeed whitelisted.

Can anyone point out where I have gone wrong or how to fix this problem?

Many thanks in advance!


#2

Hey @andrewApposing,

Thanks for the detailed post - kudos!

A couple of points - first is that not all users will have an email address, second, users can login with Twitter, but choose not to share their email address. When you’re testing this out, do you have a Twitter account with an email address and explicitly sharing it with the app?

-Mike


#3

Hi @bonnell,

Thanks for the post. I’ve double checked my Twitter account and all my details are correct. Furthermore, under the Settings -> Applications section, my App has the following permissions:

Permissions: read, write, and direct messages
Has access to your email address
Approved: Monday, November 9, 2015 at 4:05:03 PM

I can’t see any reason why this code isn’t working for and was wondering if this is an issue with the latest version of Fabric or whether I have done something incorrect in my code?

Many thanks
Andrew


#4

Thanks Andrew, can you DM me @fabric, the apps.twitter.com key that you’re using or send it into support(at)fabric(dot)io?


#5

Hi @bonnell,

The issue has now been resolved.

My app’s info.plist had the incorrect consumer key. When I set up Fabric for the first time, it put a consumer key in my info.plist which was different from my App’s consumer key. I am surprised the iOS Twitter reference guide didn’t mention this.

Thanks for your help
Andrew


#6

Glad to hear you’re all set @andrewApposing. I’ll let the team know that was unclear!


#7