Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 779
Mak13 Avatar asked Jan 27 '15 09:01

Mak13


People also ask

How do I get read and write permissions for Twitter API?

App settings -> User authentication Settings -> Edit. This will grant read and write permission to the app for the account that owns the app.


4 Answers

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);
            }
        }
    }
like image 87
Chanchal Raj Avatar answered Oct 20 '22 13:10

Chanchal Raj


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

like image 31
Harshil Kotecha Avatar answered Oct 20 '22 12:10

Harshil Kotecha


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!

like image 30
Marie Dm Avatar answered Oct 20 '22 12:10

Marie Dm


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 !!!

like image 4
NSPratik Avatar answered Oct 20 '22 12:10

NSPratik