0

Here is the code I am using to access the twitter account stored on the device; it tends to take around 30 seconds to load on my device (it is much faster on the simulator)

ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account
                              accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

[account requestAccessToAccountsWithType:accountType
                                 options:nil completion:^(BOOL granted, NSError *error)
 {
     if (granted == YES)
     {
         NSArray *arrayOfAccounts = [account
                                     accountsWithAccountType:accountType];

         if ([arrayOfAccounts count] > 0)
         {
             self.twitterAccount =
             [arrayOfAccounts lastObject];

             UIAlertView* loggedInAlert = [[UIAlertView alloc] initWithTitle:@"Success!" message:@"Successfully logged in to Twitter" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
             [loggedInAlert show];
         }
         else {
             NSLog(@"There are not any accounts to post to");
             self.twitterAccount = NULL;
             UIAlertView* noAccountAlert = [[UIAlertView alloc] initWithTitle:@"No Twitter Account Found" message:@"Check the settings of your device and make sure you are logged in to Twitter" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
             [noAccountAlert show];
         }
     } else {
         UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Authentication Failed" message:@"Failed to gain access to Twitter account" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
         [alert show];
     }
 }];
user3491833
  • 61
  • 1
  • 3
  • Do you have network conditioning enabled on the device? – klcjr89 Jul 16 '14 at 01:42
  • I haven't ever enabled it. But even if that is something I need to do, I wouldn't be able to reasonably expect that of other users, would I? – user3491833 Jul 17 '14 at 20:57
  • NO don't. Network conditioning is to purposely slow down the connection for testing purposes. Users won't have this option. – klcjr89 Jul 17 '14 at 21:11

0 Answers0