Ios 6 と Twitter を統合して、slcomposeviewcontroller を使用してツイートを送信しようとしていますが、Twitter アカウントからユーザー情報を取得する方法がわかりません。
誰でも私を助けることができますか?
Ios 6 と Twitter を統合して、slcomposeviewcontroller を使用してツイートを送信しようとしていますが、Twitter アカウントからユーザー情報を取得する方法がわかりません。
誰でも私を助けることができますか?
あなたは正しい道を進んでいましたが、間違ったフレームワークを使用していました. ソーシャル フレームワークの SLComposeViewController クラスは、共有のみを目的としています。現在サインインしているアカウントに関する情報を取得する場合は、Accounts Frameworkを使用する必要があります。
#import <Accounts/Accounts.h>
- (void)getTwitterAccountInformation
{
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
if(granted) {
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
if ([accountsArray count] > 0) {
ACAccount *twitterAccount = [accountsArray objectAtIndex:0];
NSLog(@"%@",twitterAccount.username);
NSLog(@"%@",twitterAccount.accountType);
}
}
}];
}