Skip to content

Commit

Permalink
Fix the way the SDK interprets UIWebViewDelegate errors
Browse files Browse the repository at this point in the history
Summary:
Currently if the facebook app encounters a UIWebViewDelegate error, it passes
it to the sdk in the error_code parameter. The SDK should know that if this
parameter is passed, an error occurred, which implies the user *didn't* cancel.
This fixes it.

Test Plan:
disconnected my laptop from the internet, went through the sso flow, verified
the sdk set userDidCancel to NO before calling [self
fbDialogNotLogin:userDidCancel].

DiffCamp Revision: 180310
Reviewed By: brent
CC: brent
Revert Plan:
OK
  • Loading branch information
Yariv Sadan authored and Yariv Sadan committed Nov 9, 2010
1 parent 74ac893 commit 9eaf94f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Facebook.m
Expand Up @@ -251,22 +251,28 @@ - (BOOL)handleOpenURL:(NSURL *)url {
// If the URL doesn't contain the access token, an error has occurred.
if (!accessToken) {
NSString *errorReason = [params valueForKey:@"error"];

// If the error response indicates that we should try again using Safari, open
// the authorization dialog in Safari.
if (errorReason && [errorReason isEqualToString:@"service_disabled_use_browser"]) {
[self authorizeWithFBAppAuth:NO safariAuth:YES];
return YES;
}

// If the error response indicates that we should try the authorization flow
// in an inline dialog, do that.
if (errorReason && [errorReason isEqualToString:@"service_disabled"]) {
[self authorizeWithFBAppAuth:NO safariAuth:NO];
return YES;
}

BOOL userDidCancel = !errorReason || [errorReason isEqualToString:@"access_denied"];
// The facebook app may return an error_code parameter in case it
// encounters a UIWebViewDelegate error. This should not be treated
// as a cancel.
NSString *errorCode = [params valueForKey:@"error_code"];

BOOL userDidCancel =
!errorCode && (!errorReason || [errorReason isEqualToString:@"access_denied"]);
[self fbDialogNotLogin:userDidCancel];
return YES;
}
Expand Down

0 comments on commit 9eaf94f

Please sign in to comment.