2014-07-15 5 views
0

내가 두 개의 레이블목적 C는

이러한 프로파일 이름

IIF는 설정 페이지 설정에서 점점되어야에 페이스 북과 트위터 프로필 이름을 표시해야하는 초기 설정 거기에 어떤 페이스 북 계정 설정을 설정에서 사용자 이름을 얻고 내 애플 리케이션에 displaued 지저귀다 설정도 똑같이 그것을 달성하는 방법.

감사합니다,

확인 설정 에서

enter image description here

! [여기 이미지 설명을 입력합니다] [2]

! [여기 이미지 설명을 입력합니다] [3]

+0

_ "페이스 북과 트위터 프로필 이름을 두 개의 레이블"_ _에 표시해야합니다. 아직 피싱 앱인가요? – holex

답변

0

소셜 프레임 워크를 사용하면 계정 세부 정보를 얻을 수 있습니다 -

ACAccountStore *accountStore = [[ACAccountStore alloc] init] ; 

ACAccountType *twitterAccountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; 
[accountStore requestAccessToAccountsWithType:twitterAccountType withCompletionHandler:^(BOOL granted, NSError *error) 
{ 
    if(granted) 
    { 
     NSArray *twitterAccounts = [accountStore accountsWithAccountType:twitterAccountType]; 
     NSLog(@"twitterAccounts %@", twitterAccounts); 
    } 
}]; 


ACAccountType *facebookAccountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; 
//your app id is the key, i have used "Demo". 
NSDictionary *dictFB = [NSDictionary dictionaryWithObjectsAndKeys:@"Demo", ACFacebookAppIdKey,@[@"email"],ACFacebookPermissionsKey, nil]; 

[accountStore requestAccessToAccountsWithType:facebookAccountType options:dictFB completion: 
^(BOOL granted, NSError *e) { 
    if (granted) { 
     NSArray *facebookAccounts = [accountStore accountsWithAccountType:facebookAccountType]; 
     // fb accounts 
     NSLog(@"facebook accounts =%@", facebookAccounts); 
    } else { 
     //Error 
     NSLog(@"error getting permission %@",e); 
    } 
}]; 

마찬가지로 두 개 이상의 계정이 구성된 경우 해당 계정을 반복하여 정보를 얻을 수 있습니다.

편집 - ACFacebookAppIdKey, ACFacebookPermissionsKey 란 무엇입니까?

ACCOUNTS_EXTERN NSString * const ACFacebookAppIdKey NS_AVAILABLE(NA, 6_0);   // Your Facebook App ID, as it appears on the Facebook website. 
ACCOUNTS_EXTERN NSString * const ACFacebookPermissionsKey NS_AVAILABLE(NA, 6_0);  // An array of of the permissions you're requesting. 
+0

NSArray * facebookAccounts 및 twitterAccounts가 빈 부분을 반환합니다. 설정에 계좌 설정이 있습니다. ' –

+0

계정에 대한 액세스를 요청하고 업데이트 된 답변을 확인해야합니다. – rishi

+0

iOS7에서만 facebook 용 nill 배열을 반환하고 permission에 대해 오류를 반환합니다. Facebook 서버가이 액세스 요청을 수행 할 수 없습니다. 잘못된 응용 프로그램 ID –