Logout from Facebook programmatically iOS

前端 未结 6 1040
不思量自难忘°
不思量自难忘° 2020-12-29 03:53

I am trying to logout from Facebook programmatically without using FBSDKLoginButton i had search how could I do i found this answer Can we logout facebook pro

6条回答
  •  悲&欢浪女
    2020-12-29 04:16

    FBSDKLoginManager is your need, it has logOut method but you might have to use your custom login

    e.g.

    FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
    [loginManager logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
      if (error) {
        // Process error
      } else if (result.isCancelled) {
        // Handle cancellations
      } else {
        // If you ask for multiple permissions at once, you
        // should check if specific permissions missing
        if ([result.grantedPermissions containsObject:@"email"]) {
          // Do work
        }
      }
    }];
    
    //then logout
    [loginManager logOut];
    

提交回复
热议问题