2012-12-18 8 views
7

Gibt es eine Möglichkeit, mit FACEBOOK SDK 3.1 und iOS 6 zu erfahren, wenn der Benutzer sein Facebook-Konto in den iPhone-Einstellungen für native Facebook-Nutzung definiert hat?Erkennen, ob ein Benutzer ein natives Facebook-Konto in iOS 6-Einstellungen definiert hat

Was ich tun möchte, ist beim Öffnen meiner App, wenn der Benutzer ein "natives Facebook-Konto" in iPhone-Einstellung definiert, sofort zeigen die "erlauben/nicht" iOS 6 Warnung. Aber ich möchte es nur für native Integration tun. Was ich meine, ist, dass wenn ich weiß, ich kann einfach eine "openSession" mit FBSession versuchen, und es wird es zeigen, aber wenn Benutzer das native Konto nicht definiert hat, möchte ich nicht die App zu Safari oder Facebook gehen App Ich möchte versuchen, nur eine Verbindung herzustellen, wenn der Benutzer ein Konto definiert hat.

weiß jemand einen Weg zu wissen?

+0

Das hier beantwortet wurde: http://stackoverflow.com/a/12811583/312312 – Lefteris

+1

Hey erste Dank zuzuteilen !!! Problem ist, dass es scheint, dass selbst wenn ein Konto konfiguriert wurde oder nicht ACAccountType * at = [als accountTypeWithAccountTypeIdentifier: @ "com.apple.facebook"]; at scheint nicht in ios 6 zu sein –

Antwort

2

Das ist für mich funktioniert:

//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; 
}]; 
Verwandte Themen