I try to access my user's iOS default Twitter account.
I use STTwitter library. The below code used to work fine on my device, but now it's not. The returned "oAuthToken", "oAuthTokenSecret", and "userID" are nil. but it's still working on the simulator
STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerName:nil
consumerKey:@"myConsumerKey"
consumerSecret:@"myConsumerSecret"];
[twitter postReverseOAuthTokenRequest:^(NSString *authenticationHeader) {
STTwitterAPI *twitterAPIOS = [STTwitterAPI twitterAPIOSWithFirstAccount];
[twitterAPIOS verifyCredentialsWithSuccessBlock:^(NSString *username) {
[twitterAPIOS postReverseAuthAccessTokenWithAuthenticationHeader:authenticationHeader
successBlock:^(NSString *oAuthToken,
NSString *oAuthTokenSecret,
NSString *userID,
NSString *screenName) {
// use the tokens...
self.oAuthToken = oAuthToken;
self.oAuthTokenSecret = oAuthTokenSecret;
if(self.oAuthToken && self.oAuthTokenSecret){
completionHandler();
}
else{
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
[account renewCredentialsForAccount:[arrayOfAccounts firstObject] completion:^(ACAccountCredentialRenewResult renewResult, NSError *error) {
[self getUserTwitterDataFromPhoneSettingsInView:view WithCompletionHandler:completionHandler];
}];
}
} errorBlock:^(NSError *error) {
// Error
}];
} errorBlock:^(NSError *error) {
// no twitter account
// user denied access to their account(s)
}];
} errorBlock:^(NSError *error) {
// ...
}];