Skip to content
Browse files

Fix the way the SDK interprets UIWebViewDelegate errors

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...
1 parent 74ac893 commit 9eaf94fd937503b6b1a295ca5d00418de8fefa0f Yariv Sadan committed with Yariv Sadan Nov 9, 2010
Showing with 9 additions and 3 deletions.
  1. +9 −3 src/Facebook.m
View
12 src/Facebook.m
@@ -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;
}

0 comments on commit 9eaf94f

Please sign in to comment.
Something went wrong with that request. Please try again.