2015-07-20 24 views
1

我想在我的Swift項目中使用FBSession。但我不知道如何導入它。如何導入Swift中的FBSession.h

我在橋接報

#import <FBSDKCoreKit/FBSDKCoreKit.h> 
#import <FBSDKLoginKit/FBSDKLoginKit.h> 

任何想法進口這些嗎?

我試圖將代碼轉換下面斯威夫特,但我似乎無法使用FBSession

// Whenever a person opens app, check for a cached session 
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) { 

    // If there's one, just open the session silently, without showing the user the login UI 
    [FBSession openActiveSessionWithReadPermissions:@[@"public_profile"] 
            allowLoginUI:NO 
           completionHandler:^(FBSession *session, FBSessionState state, NSError *error) { 
            // Handler for session state changes 
            // Call this method EACH time the session state changes, 
            // NOT just when the session open 
            [self sessionStateChanged:session state:state error:error]; 
           }]; 

回答

1

FBSession是類曾在SDK中,頭3.X分支的名稱你導入來自4.x版本,雖然那個類不存在了。

Facebook對此有一個Upgrade Guide的文檔,它將引導您完成從3.x遷移到4.x的過程

相關問題