2012-12-18 4 views
7

사용자가 기본 Facebook 용 iPhone 설정에서 페이스 북 계정을 정의한 경우 FACEBOOK SDK 3.1 및 iOS 6을 사용하여 알 수있는 방법이 있습니까?사용자가 iOS 6 설정에서 기본 페이스 북 계정을 정의했는지 인식

내가하고 싶은 일은 내 앱을 열 때 사용자가 iPhone 설정에서 "기본 facebook 계정"을 정의한 경우 "허용/허용하지 않음"iOS 6 알림을 즉시 표시하는 것입니다. 하지만 네이티브 통합을 위해서만하고 싶습니다. 내 말은, 만약 내가 FBSession으로 "openSession"을 시도해 볼 수 있다면, 그것을 보여줄 것이지만, 사용자가 네이티브 계정을 정의하지 않았다면, 앱이 사파리 나 페이스 북으로가는 것을 원치 않는다. 앱. 따라서 사용자가 계정을 정의한 경우에만 연결하려고합니다.

누구나 알고있는 방법을 알고 있습니까?

+0

이 여기에 답하고있다 : http://stackoverflow.com/a/12811583/312312 – Lefteris

+1

안녕하세요 처음 덕분에 충당! 문제는 그것이 계정이 구성되었거나 ACAccountType * at = [as accountTypeWithAccountTypeIdentifier : @ "com.apple.facebook"]; 에 이오스가없는 것 같아요 6 –

답변

2

이 나를 위해 노력하고 있습니다 :

//Step 1. create and store an ACAccountStore in an ivar 
ACAccountStore* as = [[ACAccountStore alloc] init]; 
self.accountStore = as; 
[as release]; 

//Step 2. Get the facebook account type 
//Do not use the constant if you are in iOS5, use this string:@"com.apple.facebook" 
ACAccountType* at = [self.accountStore accountTypeWithAccountTypeIdentifier: @"com.apple.facebook"]; 

//Step 3. request access to the facebook account, passing your facebook app id 
__block typeof(self) bself = self; 
[self.accountStore requestAccessToAccountsWithType:at 
          options:@{(NSString *)ACFacebookAppIdKey: kFBAppId } 
         completion:^(BOOL granted, NSError *error) 
{ 
    //Step 4. Check if the account is integrated natively 
    //Note: if granted is NO, check for the error to see what's going on. 
    BOOL nativeAccount = granted == YES && [bself.accountStore accountsWithAccountType:at]; 


    //Step 5. clean the account store. 
    bself.accountStore = nil; 
}]; 
관련 문제