简体   繁体   中英

Facebook SDK login delegate

I'm using the latest Facebook SDK for iOS.

I have a FBLoginView in my "login" screen but there only seems to be a FBLoginViewDelegate . Can I not set a delegate on the FBSession like I used to be able to?

I want to catch actual login to Facebook. Not just the FBLoginView changing to show "Log Out" as this happens every time the app opens even if the user was already logged in and the access token was valid.

put this code to log out manually

 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];
    }

also u add this code:

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

Swift 3 IOS 10!

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

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

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM