iOS Post Media Twitter crash


I am trying to post a picture from my app to twitter account. It works fine on my 3 devices but crashes for one of my friends. I am using the following code… Wasted almost 2 days on it so far without any luck. Please see the Problem lines, app crashes on those two lines as per crashalytics. Any one has experienced this?

NSString *account_id = [PFUser currentUser][@“Twitter_ScreenName”];

        NSURL *retweetURL = [NSURL URLWithString:@""];
        NSDictionary *params = @{@"status" : [NSString stringWithFormat:@"%@#mytag",self.postTextView.text]};
        SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter
        NSData *imageData = UIImageJPEGRepresentation(self.postImage, 0.5f);
        [request addMultipartData:imageData withName:@"media[]" type:@"image/jpeg" filename:@"image.jpg"];

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

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

                 if ([twitterAccounts count] > 0)
                     ACAccount *twitterAccount;

                     for (int i=0; i<[twitterAccounts count]; i++)
                         ACAccount *acc=[twitterAccounts objectAtIndex:i];
                         if ([acc.username isEqualToString: account_id ])
                             twitterAccount = acc;



I’m not an expert in this area but it looks like maybe your friend hasn’t authorised the app to access their Twitter account in iOS?


Additionally, you may want to take a look at the newer method of posting photo media to Twitter, introduced recently [node:27935]


Hey Andy… I cannot access the link you shared. And yes, my friend gave access to the app.


That’s weird that you can’t access the link - can you try hitting the logout at the top right corner of the page and then try the link again? could be a weird permissions issue.

Is there a difference in your friend’s device / iOS version? I’m really not an expert in this area so I am just trying to help you to narrow down the possibilities at this stage.