how to request permission to retrieve user's email using twitter kit version 1.2.0 in ios8?
Asked Answered
K

5

9

I have integrated twitter kit in my ios app by following https://dev.twitter.com/twitter-kit/ios/configure this. I could sign-in after authentication and see my twitter name easily but now i want to retrieve my email address so i used TWTRShareEmailViewController which presents user a share email view which returns null. I went through the docs where they mentioned about my app to be whitelisted for requesting email permission and said to fill up this form https://support.twitter.com/forms/platform am not getting what to do next? how to get i user email permission exactly? Suggest any help. Thanks in advance.

Kania answered 27/1, 2015 at 9:57 Comment(0)
L
6

I didn't find a specific form to ask to be whitelisted neither. I went on their form link https://support.twitter.com/forms/platform and I checked the "I have an API policy question not covered by these points" option. They responded a few days after and asked me more information about the application and its app ID. I'm actually waiting for their answer.

EDIT:

So after several (a lot) emails with [email protected] and a few bugs I finally got whitelisted. But the option is currently unavailable with Fabric so you'll have to create a Twitter app on apps.twitter.com. Just send a mail with your app ID or your keys. They'll probably ask you a quick description of your app and it shouldn't take so much time to be whitelisted. Good luck!

Lunula answered 25/2, 2015 at 15:6 Comment(4)
After a lot of research i found that twitter does not support email permission for ios and android as well we had excluded twitter login from our app and just using facebook and linked as our primary requirement was to get email at any cost. Please update if you find any hack over it. thanks...Kania
I had a response today and they told me that I wasn't asking my question at the right place. They suggested me to check the API documentation (which I already did of course) and search through their developer discussion (which I also did). So I think I'm not ready to be whitelisted... When you say they don't support email permission, this is also true if you're whitelisted by Twitter? You just can't ask it at all?Lunula
I think we can get email if our app is whitelisted coz if they are providing us TWTRShareEmailViewController then it makes sense to support email permission if not i don't understand why they have provided it, but again the question arises how do i make my app being whitelisted. Check out this blog.twitter.com/2014/introducing-fabric and see sign in twitter para what it says. Update me what is to be done to get the app whitelisted.Kania
@Kania Have a look into it #28680152Jollanta
M
4

After having a conversation with [email protected], I got my App whitelisted. Here is the story:

  • Send mail to [email protected] with some details about your App like Consumer key, App Store link of an App, Link to privacy policy, Metadata, Instructions on how to log into our App. Mention in mail that you want to access user email address inside your App.

  • They will review your App and reply to you within 2-3 business days.

  • Once they say that your App is whitelisted, update your App's settings in Twitter Developer portal. Sign in to apps.twitter.com and:

    1. On the 'Settings' tab, add a terms of service and privacy policy URL
    2. On the 'Permissions' tab, change your token's scope to request email. This option will only been seen, once your App gets whitelisted.

It's time to code:

-(void)requestUserEmail
{
    if ([[Twitter sharedInstance] session]) {

        TWTRShareEmailViewController *shareEmailViewController =
        [[TWTRShareEmailViewController alloc]
         initWithCompletion:^(NSString *email, NSError *error) {
             NSLog(@"Email %@ | Error: %@", email, error);
         }];

        [self presentViewController:shareEmailViewController
                           animated:YES
                         completion:nil];
    } else {
        // Handle user not signed in (e.g. attempt to log in or show an alert)
    }
}

Hope it helps !!!

Mckinley answered 27/5, 2015 at 8:38 Comment(2)
Thank you for the detailed steps. Unfortunately, the email I sent t o [email protected] was returned as undeliverable. I'll submit my email to [email protected] as the other poster suggested and as a last resort, go through their support form and hope it gets to the right place.Rowel
@Mckinley Above method is not valid from tomorrow, can you help me with new method. Check here "docs.fabric.io/ios/twitter/request-user-email-address.html"Leggett
T
3

Send email to [email protected] to whitelist your twitter login app first.

Swift 3.0 Code with fabric

@IBAction func btnTwitterAction(_ sender: AnyObject) {
        Twitter.sharedInstance().logIn { (session, error) in
            if session != nil {
                print("signed in as \(session!.userName)");
                let client = TWTRAPIClient.withCurrentUser()
                let request = client.urlRequest(withMethod: "GET",
                                                url: "https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true",
                                                          parameters: ["include_email": "true", "skip_status": "true"],
                                                          error: nil)
                client.sendTwitterRequest(request) { response, data, connectionError in
                    if (connectionError == nil) {

                        do{
                            let json = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! [String:Any]
                            print("Json response: ", json)
                            let firstName = json["name"]
                            let lastName = json["screen_name"]
                            let email = json["email"]
                            print("First name: ",firstName)
                            print("Last name: ",lastName)
                            print("Email: ",email)
                        } catch {

                        }

                    }
                    else {
                        print("Error: \(connectionError)")
                    }
                }


            } else {
                NSLog("Login error: %@", error!.localizedDescription);
            }
        }
    }
Tele answered 1/11, 2016 at 17:8 Comment(5)
Everything works fine in this code except getting the email address : it returns nil.Apps
@Fadwa_lmh, did you get your twitter app whitelisted by sending an email to [email protected]?Tele
@ChanchalRaj, yes my twitter app is whitelisted!Apps
@Fadwa_lmh, after getting my app whitelisted, I was able to get the email address. And it's still working fine. Maybe contact them again.Tele
@ChanchalRaj, i'll try again, thank you for your help.Apps
M
1

How to get email id in twitter ?

Step 1 : got to https://apps.twitter.com/app/

Step 2 : click on ur app > click on permission tab .

Step 3 : here check the email box

enter image description here

Metsky answered 17/10, 2017 at 10:4 Comment(0)
H
0

I've faced the same issue recently

Here is what you should try if you are using new twitter kit

Go to

Code :

Twitter.sharedInstance().logIn(withMethods: [.webBased,.systemAccounts,.all]) {(session, error) -> Void in

        if (session != nil) {
            print("signed in as \(session?.userName)");

            let client = TWTRAPIClient(userID: session?.userName)
            client.loadUser(withID: (session?.userID)!, completion: { (user, error) in

                let twitterClient = TWTRAPIClient.withCurrentUser()
                let request = twitterClient.urlRequest(withMethod: "GET",
                                                url: "https://api.twitter.com/1.1/account/verify_credentials.json",
                                                parameters: ["include_email": "true", "skip_status": "true"],
                                                error: nil)


                twitterClient.sendTwitterRequest(request) { response, data, connectionError in

                    print(data!)

                    let s :String = String(data: data! as Data, encoding: String.Encoding.utf8)!
                    //
                    //            let json = try JSONSerialization.jsonObject(with: responseData as Data, options: JSONSerialization.ReadingOptions.mutableLeaves) as? [String:AnyObject]
                    //

                    Twitter.sharedInstance().sessionStore.logOutUserID((session?.userID)!)

                    if let data = s.data(using: String.Encoding.utf8) {
                        do {
                            let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String:Any]
                            print(json!)

                        } catch {
                            print("Something went wrong")
                        }
                    }
                }
            })

        } else {
   }
Herson answered 9/3, 2017 at 8:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.