Search code examples
iosobjective-cfacebook-ios-sdk

How to clear the credentials of facebook in ios application, when i hit on back to app button on the top in safari browser?


I tried doing [FBSDKAccessToken setCurrentAccessToken:nil]; [FBSDKProfile setCurrentProfile:nil]; even after doing this and after running the application, I entered different credential to login to Facebook app, but it is still taking the previously entered credentials. So my question is how to clear or delete the credentials. Please someone help me in doing this. Thanks in advance for spending your time to go through this question and answering.


Solution

  • try this

    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me/permissions/"
       parameters:nil
       HTTPMethod:@"DELETE"]
     startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id  result, NSError *error) {
      // ...
     }];
    

    there after add your facebook login code

    for additional information see this

    or choice -2

    FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
    
    if ( [FBSDKAccessToken currentAccessToken] ){
        [login logOut];
         [FBSDKAccessToken setCurrentAccessToken:nil];
        [FBSDKProfile setCurrentProfile:nil];
    }