2012-09-14 62 views
2

嗨,我正在閱讀和閱讀教程在這裏http://developers.facebook.com/Xcode Facebook登錄錯誤關閉

關於登錄Facebook和發佈應用程序的飼料,我的問題是我根本無法登錄Facebook。

而我無法得到它的工作。它很糟糕,並且沒有關於此的明確教程/解釋。

我試着在Safari中打開,然後將URL都像要瘋了 閃爍,從我的應用程序,登錄..

而且我沒有得到一個錯誤,爲什麼呢?

有沒有CLEAR教程關於登錄?

它在模擬器上工作很好,但在設備上不起作用。

Im現在在Xcode 4.5 beta上,但它也不適用於4.4。

我需要幫助!

[CLOSED]

編輯:我定了!我太愚蠢了......我在七天內掙扎着登錄FB, 然後我改變了(Cookies允許在設備上),一切都很完美!

該死該設備只是需要一些餅乾..洛爾

回答

0

我剛剛更新到最新的SDK FB大約2個星期前。下面是我用同樣的方式:

//FB recommends to put these two in the app delegate in their sample apps but you can place them other places 
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI { 
    NSArray *permissions = [NSArray arrayWithObjects:@"publish_actions", nil]; 
    return [FBSession openActiveSessionWithPermissions:permissions 
              allowLoginUI:allowLoginUI 
            completionHandler:^(FBSession *session, FBSessionState state, NSError *error) { 
             NSLog((@"session.state is %d",session.state)); 
             if(session.state==513){ 
              [AppPrefererences sharedAppPrefererences].faceBookLoggedIn=YES; 
              NSLog((@"facebookLogin pref has been set to yes from inside appDelegate")); 
             } 
             else{ 
              [AppPrefererences sharedAppPrefererences].faceBookLoggedIn=NO; 
             } 
            }]; 
} 

- (BOOL)application:(UIApplication *)application 
      openURL:(NSURL *)url 
    sourceApplication:(NSString *)sourceApplication 
     annotation:(id)annotation { 
    // FBSample logic 
    // We need to handle URLs by passing them to FBSession in order for SSO authentication 
    // to work. 
    return [FBSession.activeSession handleOpenURL:url]; 
} 


    //Then whereever you want to initiate the log in (i use mine in a tableView) 
     AppDelegate *appDelegate =(AppDelegate*) [[UIApplication sharedApplication]delegate]; 

if (![appDelegate openSessionWithAllowLoginUI:NO]) { 
        [appDelegate openSessionWithAllowLoginUI:YES]; 
        [email protected]"Facebook Log Out"; 
        [AppPrefererences sharedAppPrefererences].faceBookEnabled=YES; 
       } 
       else{ 
        [email protected]"Facebook Log In"; 
        [AppPrefererences sharedAppPrefererences].faceBookLoggedIn=NO; 
        [FBSession.activeSession closeAndClearTokenInformation];      
       } 

然後whererever您想發表你這樣做:

[FBRequestConnection startForPostStatusUpdate:@"any thing you want to post" 
            completionHandler:^(FBRequestConnection *connection, id result, NSError *error){}]; 

而且,也不要忘記設置FBLoginViewDelegate

設我知道你是否有任何問題!希望能幫助到你!

+0

什麼是AppPreferences? – Stackie

+0

哦,我的不好,那只是我用來實現nsuserdefaults的自定義類。只是忽略這一部分 –