2012-12-18 20 views
7

Kullanıcı, facebook hesabını yerel facebook kullanımı için iPhone ayarlarında tanımladıysa FACEBOOK SDK 3.1 ve iOS 6 ile tanışmanın bir yolu var mı?Kullanıcı, iOS 6 ayarlarında yerel bir facebook hesabı tanımladıysa tanıma

Uygulamamı açarken yapmak istediğim, kullanıcı iPhone ayarlarında "yerel bir facebook hesabı" tanımladıysa, hemen "izin ver/izin verme" iOS 6 uyarısını göster. Ama bunu sadece yerel entegrasyon için yapmak istiyorum. Demek istediğim, eğer FBSession ile bir "openSession" deneyebileceğimi bildiğim ve bunu gösterecektir, ancak kullanıcı yerel hesabı tanımlamazsa, uygulamanın Safari'ye veya facebook'a gitmesini istemiyorum Uygulamanın. Bu yüzden sadece kullanıcı bir hesap tanımlamışsa bağlanmayı denemek istiyorum.

Herkes bilmek için bir yol biliyor mu?

+0

Bu burada yanıtlandı: http://stackoverflow.com/a/12811583/312312 – Lefteris

+1

Hey ilk teşekkür tahsis !!! Bir hesap yapılandırılmış veya ACAccountType * at = [hesapTypeWithAccountTypeIdentifier: @ "com.apple.facebook" olarak]; ios içinde nil görünmüyor 6 –

cevap

2

Bu benim için çalışıyor:

//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; 
}]; 
İlgili konular