Login with twitter in ios 7

你说的曾经没有我的故事 提交于 2019-12-03 04:05:55

First of all, you can not get user email address from twitter's API either using iOS7 framework or Twitter's Native API.
If you want to get user email address you can ask user to enter it manually. That's what Twitter people say in their API Docs. For your Point 2 and 3 here is the sample code using iOS7 way

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) // check Twitter is configured in Settings or not
{
    self.accountStore = [[ACAccountStore alloc] init]; // you have to retain ACAccountStore

    ACAccountType *twitterAcc = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

    [self.accountStore requestAccessToAccountsWithType:twitterAcc options:nil completion:^(BOOL granted, NSError *error)
     {
         if (granted)
         {
             self.twitterAccount = [[self.accountStore accountsWithAccountType:twitterAcc] lastObject];
             NSLog(@"Twitter UserName: %@, FullName: %@", self.twitterAccount.username, self.twitterAccount.userFullName);
             [self getTwitterEmail]; // here you can ask user to enter email address. Its up to you how you ask user about it. Either in alert View or in Text Field.
         }
         else
         {
             if (error == nil) {
                 NSLog(@"User Has disabled your app from settings...");
             }
             else
             {
                 NSLog(@"Error in Login: %@", error);
             }
         }
     }];
}
else
{
    NSLog(@"Not Configured in Settings......"); // show user an alert view that Twitter is not configured in settings.
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!