I am using Facebook
to create a new user or log in to Parse.
4. User removed permission for app (delete app from Facebook)
I am wondering what is the way for us to check if the user has change the authorization status of the app in Facebook.
How do I check it? How do we know that it is no longer connected?
FBSDKAccessToken.currentAccessToken();
does not do the job, as it can only check if the token exists or not in the device.
I.E.: The user goes to Facebook App settings and deleted the App from the list.
p.s.: Please help vote up this question as It's really hard to find the solution. Thank you!!
Thank you
Handling an Invalidated Session
We cannot know if the cached Facebook session is valid until we attempt to make a request to the API. A session can become invalidated if a user changes their password or revokes the application's privileges. When this happens, the user needs to be logged out. We can identify an invalid session error within a FBSDKGraphRequest completion handler and automatically log the user out.
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
// handle successful response
} else if ([[error userInfo][@"error"][@"type"] isEqualToString: @"OAuthException"]) { // Since the request failed, we can check if it was due to an invalid session
NSLog(@"The facebook session was invalidated");
[PFFacebookUtils unlinkUserInBackground:[PFUser currentUser]];
} else {
NSLog(@"Some other error: %@", error);
}
}];
Source: Integrate Login with Facebook
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With