1

I'm trying to login in twitter using Fabric sdk. I need to get the user image profile, email and name but all I can get is username with the following method:

Twitter.sharedInstance().logInWithCompletion { (session: TWTRSession?, error: NSError?) in
       self.name = session?.userName
}

According to this link you need to request Twitter to put your app into its whitelist. https://docs.fabric.io/apple/twitter/log-in-with-twitter.html

Is it necessary? Anyone has another solution? Thanks!

Morgan
  • 4,143
  • 27
  • 35
Marta Tenés
  • 2,102
  • 1
  • 13
  • 22
  • 1
    According to the documentation, it is a requirement to have your app be whitelisted by Twitter to get the user's email address. As far as I know, there is no way around this. It wouldn't be a very good requirement if there was a way to circumvent it. – Daniel Zhang Aug 11 '16 at 09:52
  • yeah @Daniel i know, but at least the name and profile image... – Marta Tenés Aug 11 '16 at 09:55
  • 1
    see this http://stackoverflow.com/questions/30235010/get-user-profile-details-especially-email-address-from-twitter-in-ios – Anbu.Karthik Aug 11 '16 at 09:56
  • 1
    @MartaTenés You just need to get the `TWTRUser` object to able to read the name and profile image like in the answer that @Anbu.Karthik linked. – Daniel Zhang Aug 11 '16 at 10:21
  • Thank you, I used the method in the link and now I can obtain the image and name with TWTRUser but it will be soon deprecated according with this log: " -[Twitter APIClient] will soon be deprecated. This method can return unexpected results based on who is logged in or logged out. It is recommended that users use -[TWTRAPIClient initWithUserID:] for more explicit control over which user is making requests." – Marta Tenés Aug 11 '16 at 10:51
  • Thanks for the info on the deprecated code. Looks like the `TWTRUser` will be obtainable from `TWTRLoadUserCompletion` in loadUserWithID:completion:. I didn't see initWithUserID: in the docs but it could be new. – Daniel Zhang Aug 11 '16 at 18:31
  • @Daniel I edited my question with the answer :) – Marta Tenés Aug 12 '16 at 09:54
  • @MartaTenés Looks good. Those conditions keep changing and it gets cumbersome to keep track of them. I'd suggest posting the answer in the answer here rather than in the question because I think that would fit the Q&A format better. It's certainly useful research that you have done. – Daniel Zhang Aug 12 '16 at 10:32
  • Thanks @MartaTenés. – Daniel Zhang Aug 12 '16 at 13:50

2 Answers2

1

According to twitter is it a must to create the app from apps.twitter.com. If you create the app with fabric there is no way to get the user's email. I paste here twitter answer:

"Developers can now directly enable email requesting permission for all apps created via apps.twitter.com. To proceed simply log into your app at apps.twitter.com and add links to your Terms and Conditions and Privacy Policy under the Settings tab. Then, check the Request email addresses from users box under the Permissions tab. Please visit our Developers Forum for any technical questions regarding this permission.

Note for Fabric Apps: Email requesting permission is only available for apps created via apps.twitter.com. To proceed please create a new key there, and then respond to this email with this new app ID. We will then add Fabric permissions to it.

Currently there is no way to combine apps.twitter.com apps with those created via fabric.io. We appreciate your understanding."

Marta Tenés
  • 2,102
  • 1
  • 13
  • 22
0

when you create app at apps.twitter.com checkmark "request email addresses from user " in additional permission under Permissions as shown in image and you can set you consumer key and access token in plist with fabric app's credential hope will work for you.