aws-sdk-ios icon indicating copy to clipboard operation
aws-sdk-ios copied to clipboard

[Crash] SDK 2.36.0 AWSCognitoAuth launchUsing:uiViewController:completion:

Open skyfoxa opened this issue 1 year ago • 6 comments

Describe the bug Calling AWSMobileClient.default().showSignIn(navigationController: signInUIOptions: hostedUIOptions: _:) leads to an uncaught exception and crashes the app.

This issue started occurring when we updated the SDK from version 2.35.0 to 2.36.0. It's probably connected to the recent update from SFAuthenticationSession to ASWebAuthenticationSession. It may be the same issue as was discussed here

To Reproduce

Here is our awsconfiguration:

"Auth": {
      "Default": {
        "OAuth": {
          "WebDomain": "...",
          "AppClientId": "....",
          "SignInRedirectURI": "myapp://callback",
          "SignOutRedirectURI": "myapp://signout",
          "Scopes": ["openid", "email", "profile"]
        }
      }
    },

Steps to reproduce the behavior:

  1. Call AWSMobileClient.default().showSignIn(navigationController:signInUIOptions:hostedUIOptions:_:)
    • use HostedUIOptions(scopes: ["openid", "email", "profile"], identityProvider: "Google")

Observed Behavior

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".'

Expected Behavior Hosted UI is opened and user can sign in, app doesn't crash.

Stack Trace image

Code Snippet

Unique Configuration

Areas of the SDK you are using (AWSMobileClient, Cognito, Pinpoint, IoT, etc)? AWSMobileClient

Screenshots

Environment(please complete the following information):

  • SDK Version: 2.36.0
  • Dependency Manager: SPM
  • Swift Version : 5.10
  • Xcode Version: 15.3

Device Information (please complete the following information):

  • Device: iPhone 13 pro, iPhone 15 Pro
  • iOS Version: iOS 17.4.1
  • Specific to simulators:

Additional context

Relevant Console Output

Logs

Log Messages
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".'
*** First throw call stack:
(0x1a677ab28 0x19e5eaf78 0x21e71b618 0x21e71b214 0x10bb3dc10 0x10bb3dae0 0x10bb3da4c 0x1a55687f4 0x1a5596d0c 0x1a5594594 0x1a5593684 0x1a559619c 0x1a5595f08 0x10c617764 0x10c6067bc 0x10c6098e0 0x10c608bb8 0x10c61aae4 0x10c61b4d8 0x202670ee4 0x202670fc0)
libc++abi: terminating due to uncaught exception of type NSException

skyfoxa avatar May 03 '24 11:05 skyfoxa

Hi @skyfoxa! Thanks for opening this issue.

We will take a look and post updates here.

sebaland avatar May 03 '24 14:05 sebaland

This should be fixed in the latest release 2.36.1.

Could you please update your dependency and verify? Thanks!

sebaland avatar May 03 '24 23:05 sebaland

@ruisebas the SDK doesn't crash anymore, however it won't open the hosted UI, calling the AWSMobileClient.default().showSignIn(navigationController: signInUIOptions: hostedUIOptions: _:) method returns this error:

Error Domain=com.apple.AuthenticationServices.WebAuthenticationSession Code=2 "Cannot start ASWebAuthenticationSession without providing presentation context. Set presentationContextProvider before calling -start." UserInfo={NSDebugDescription=Cannot start ASWebAuthenticationSession without providing presentation context. Set presentationContextProvider before calling -start.}

skyfoxa avatar May 06 '24 09:05 skyfoxa

@skyfoxa my apologies for that.

I've merged a fix to the main branch. Would you be able to verify it it addresses your issues? If you cannot, no worries, we will release a new version for you to try.

Thanks!

sebaland avatar May 06 '24 15:05 sebaland

@ruisebas I tried it, but it looks https://github.com/aws-amplify/aws-sdk-ios-spm doesn't contain that change yet, I'll probably wait for the release

skyfoxa avatar May 07 '24 13:05 skyfoxa

@skyfoxa sorry for the delay. The fix has been released in 2.36.2.

Please let us know if you still face any issues. Thanks!

sebaland avatar May 14 '24 13:05 sebaland