2013-07-11 84 views
0

我正在使用適用於iOS的最新Facebook SDK。Facebook SDK登錄代理

我在我的「登錄」屏幕上有一個FBLoginView,但似乎只有一個FBLoginViewDelegate。我可以不像我曾經能夠設置FBSession的代表嗎?

我想趕上實際登錄到Facebook。不僅FBLoginView更改爲顯示「註銷」,因爲即使用戶已經登錄並且訪問令牌有效,每次應用程序打開時都會發生這種情況。

回答

1

把這段代碼註銷手動

FBSession* session = [FBSession activeSession]; 
    [session closeAndClearTokenInformation]; 
    [session close]; 
    [FBSession setActiveSession:nil]; 

    NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 
    NSArray* facebookCookies = [cookies cookiesForURL:[NSURL URLWithString:@"https://facebook.com/"]]; 

    for (NSHTTPCookie* cookie in facebookCookies) { 
     [cookies deleteCookie:cookie]; 
    } 

還û添加以下代碼:

- (void)applicationWillTerminate:(UIApplication *)application 
{ 
    [FBSession.activeSession close]; 
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 
} 
+0

嗨你檢查了我的答案 –

0

斯威夫特3 IOS 10!

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { 

    return SDKApplicationDelegate.shared.application(app, open: url, options: options) 

}