Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facebook Sign-in UI Fails on iOS 13 / Xcode 11 (AWSMobileClient.default().showSignIn) Facebook SDK 5.8 required. #1974

Closed
BillBunting opened this issue Oct 11, 2019 · 2 comments
Assignees
Labels
mobile client Issues related to AWSMobileClient work in progress Issues was triaged and investigation done

Comments

@BillBunting
Copy link
Contributor

BillBunting commented Oct 11, 2019

Describe the bug
FBSDK 4.42 does not support iOS 13. iOS 13 requires ASWebAuthenticationPresentationContextProviding which was added in FBSDKCoreKit/FBSDKCoreKit/Internal/BridgeAPI/FBSDKBridgeAPI.m in 5.4.0

After upgrading from Xcode10 to Xcode11 and iOS 13, the Facebook login button no longer works on the AWSMobileClient sign in screen. When the button is pushed, an error is returned then the showSignIn() returns nil. Error: -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" Facebook is not installed in the simulator but was installed on physical device. In either case, the same error log returns and the Facebook sign-in does not appear. If the user is already singed-in to the app via Facebook and there is a valid token, then the app will login the user (just indicating that the problem is with the sign-in UI)

This problem is resolved by upgrading to the latest FBSDKs. FBSDKCoreKit must implement ASWebAuthenticationPresentationContextProviding which was resolved by

facebook/facebook-ios-sdk@6b06109#diff-72593591275d63edfb1bfad837e4c32f

Update all pods
Updating local specs repositories
Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "FBSDKCoreKit":
  In Podfile:
    AWSFacebookSignIn (~> 2.12.0) was resolved to 2.12.0, which depends on
      FBSDKCoreKit (<= 4.42)

    FBSDKShareKit (~> 5.8.0) was resolved to 5.8.0, which depends on
      FBSDKShareKit/Share (= 5.8.0) was resolved to 5.8.0, which depends on
        FBSDKCoreKit (~> 5.0)

WORKAROUND: I implemented the changes manually in 4.42 to add ASWebAuthenticationPresentationContextProviding in @interface FBSDKBridgeAPI() <FBSDKApplicationObserving, FBSDKContainerViewControllerDelegate, ASWebAuthenticationPresentationContextProviding> and it works now. This confirms that this is a bug that should affect everyone attempting to use aws-sdk-ios AWSAuthUI with Facebook.

To Reproduce
Steps to reproduce the behavior:

  1. Install new app (never signed in) or use AWSMobileClient.default().signOut();
  2. app calls AWSMobileClient.default().showSignIn
  3. AWSAutiUI displays the sign-in screen
  4. Select (touch on) "[F logo] Continue with Facebook" button.
  5. User observes nothing. showModListSignIn() callback returns signInUserState = nil

Which AWS service(s) are affected?
AWSMobileClient
AWSAuthUI
AWSAuthCore

Environment(please complete the following information):

  • SDK Version: 2.11.1
  • Dependency Manager: Cocoapods
  • Swift Version : 5

Device Information (please complete the following information):

  • Device: Any iOS (iPhone X, iPhone8, ...)
  • iOS Version: iOS 13.1 or newer (including iOS 13.2 (beta))
  • Specific to simulators: No (can be reproduced on a device or simulator)

Info.plist contains the correct settings for Facebook
The Info.plist contains fbauth2 (and it works in iOS version < 13) with the same code.

<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>fbapi</string>
		<string>fb-messenger-api</string>
		<string>fbauth2</string>
		<string>fbshareextension</string>
		<string>comgooglemaps</string>
	</array>

Fails at AWSFacebookSignInProvider self.facebookLogin
FBSDK returns UserInfo={message=User Cancelled Login}

AWSFacebookSignInProvider: line 180 (2.11.1)

   [self.facebookLogin logInWithReadPermissions:self.requestedPermissions
                              fromViewController:self.signInViewController
                                         handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {

                                             if (error) {
                                                    self.completionHandler(result, error);
                                             } else if (result.isCancelled) {
                                                 // Login canceled, allow completionhandler to know about it
                                                 NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
                                                 userInfo[@"message"] = @"User Cancelled Login";
                                                 NSError *resultError = [NSError errorWithDomain:@"com.facebook.sdk.login" code:FBSDKLoginUnknownErrorCode userInfo:userInfo];
                                                 self.completionHandler(result, resultError);
                                             } else {
                                                 [self completeLogin];
                                             }
                                         }];

FBSDKLoginManager detects that the Facebook app is not installed (when running in the simulator) and attempts to login using the safari browser

FBSDK creates the authURL: authURL as
@"https://m.facebook.com/v3.2/dialog/oauth?auth_type=rerequest&client_id=...&default_audience=friends&display=touch&e2e=%7B%22init%22%...%7D&fbapp_pres=0&redirect_uri=...%3A%2F%2Fauthorize%2F&response_type=token%2Csigned_request&return_scopes=true&scope=public_profile&sdk=ios&sdk_version=4.42.0&state=%7B%22challenge...

[[FBSDKBridgeAPI sharedInstance] openURLWithSafariViewController:authURL sender:self fromViewController:self.fromViewController handler:handlerWrapper];
returns error to handler : `anError NSError * domain: @"com.apple.AuthenticationServices.WebAuthenticationSession" - code: 2 0x000060400014b790```

resulting in facebook returning to AWSFacebookSignInProvier an indication that UserInfo={message=User Cancelled Login}, which the user did not cancel the login.

What happened is that the OS needs the window to display the OAuth Alert and Web login flow. To do that, ASWebAuthenticationSession needs to know which window is presenting the OAuth request by implementing the ASWebAuthenticationPresentationContextProviding interface in your presenting View Controller.

@BillBunting BillBunting changed the title Facebook Sign-in UI Fails on iOS 13 / Xcode 11 (AWSMobileClient.default().showSignIn) -canOpenURL: failed for URL: "fbauth2:/" Facebook Sign-in UI Fails on iOS 13 / Xcode 11 (AWSMobileClient.default().showSignIn) Facebook SDK 5.8 required. Oct 11, 2019
@drochetti drochetti added the mobile client Issues related to AWSMobileClient label Oct 11, 2019
@cornr
Copy link
Contributor

cornr commented Oct 17, 2019

This is also a major issue for basically preventing an App Update for iOS 13

@palpatim palpatim added the work in progress Issues was triaged and investigation done label Oct 21, 2019
@BillBunting
Copy link
Contributor Author

Fixed by 2.12.1. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile client Issues related to AWSMobileClient work in progress Issues was triaged and investigation done
Projects
None yet
Development

No branches or pull requests

5 participants