Facebook SDK登录代理

时间:2013-07-11 10:31:55

标签: ios objective-c facebook-ios-sdk

我正在使用适用于iOS的最新Facebook SDK。

我的“登录”屏幕中有FBLoginView,但似乎只有FBLoginViewDelegate。我可以不像以前那样在FBSession上设置代理吗?

我想抓住实际登录Facebook。不仅FBLoginView更改为显示“退出”,因为每次应用程序打开时都会发生这种情况,即使用户已经登录且访问令牌有效。

2 个答案:

答案 0 :(得分: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:.
}

答案 1 :(得分:0)

Swift 3 IOS 10!

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

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

}