Amplify-ios: Amplify.Auth.signInWithWebUI() Crashes due to Scheme Validation in Xcode

Created on 3 Mar 2021  路  4Comments  路  Source: aws-amplify/amplify-ios

Describe the bug
Amplify.Auth.signInWithWebUI() crashes app due to scheme validation. The app is not accepting a URL scheme with "://" in it. This is not allowing a user to sign in via WebUI.

Xcode produces the following response:

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

AWS Amplify documentation does not mention a step to avoid this behavior.

To Reproduce
Steps to reproduce the behavior:

  1. Setup locally by following AWS Amplify iOS authentication documentation :
    https://docs.amplify.aws/lib/auth/getting-started/q/platform/ios
  2. Push Amplify to backend
  3. Add URL scheme to info.plist
     <key>CFBundleURLTypes</key>
     <array>
         <dict>
             <key>CFBundleURLSchemes</key>
             <array>
                 <string>myapp</string>
             </array>
         </dict>
     </array>
  1. Initialize Amplify plugins in AppDelegate.swift
  2. Call the below method
func signInWithWebUI() {
    Amplify.Auth.signInWithWebUI(presentationAnchor: self.view.window!) { result in
        switch result {
        case .success:
            print("Sign in succeeded")
        case .failure(let error):
            print("Sign in failed \(error)")
        }
    }
}

Expected behavior
WebUI window to opens up to allow for user sign in.

Screenshots
amplifyconfiguration.json
Screen Shot 2021-03-03 at 2 39 37 PM

Environment:

  • Amplify Framework Version: [1.6.1]
  • Dependency Manager: Cocoapods
  • Swift Version: 5
  • CLI Version: [4.44.2]

Device Information:

  • Device: iPhone XR
  • iOS Version: 14.5
auth bug pending release

Most helpful comment

Fix is merged into the SDK. We'll need to release the SDK, then do an Amplify release that updates dependencies in Podfile.lock we ship. However, after we do the SDK release, a pod update in your app project should update Amplify's dependencies to the latest, assuming I haven't misremembered something about CocoaPods dependency resolution.

All 4 comments

@ncrews35

We think we've found the cause of the error message, but I don't see that it crashes the app. In my testing, the app continues with the HostedUI flow and a user is able to sign in successfully.

However, that behavior may be because I'm running in a debugger; additional optimizations may apply in release mode that change that behavior, and in any case, we don't want to invoke our ASWebAuthenticationSession with incorrect data. We'll get this fix and update this ticket when we have more info.

Fix is merged into the SDK. We'll need to release the SDK, then do an Amplify release that updates dependencies in Podfile.lock we ship. However, after we do the SDK release, a pod update in your app project should update Amplify's dependencies to the latest, assuming I haven't misremembered something about CocoaPods dependency resolution.

@ncrews35

The AWS Mobile SDK for iOS 2.23.1 release is complete.

You should be able to do a pod update on your project and have it update to the latest dependencies.

@palpatim

Everything is working great. Thanks for the help!

Was this page helpful?
0 / 5 - 0 ratings