SCSDKLoginClient's completion is called twice

We convert SCSDKLoginClient.login(from:) from a completion handler to async await here. We were getting a bunch of crashes because continuation.resume() was being called twice - meaning the completion handler was being called twice.

@MainActor
func login(from viewController: UIViewController) async throws -> Bool {
    var completed = false

    return try await withCheckedThrowingContinuation { continuation in
        SCSDKLoginClient.login(from: viewController) { success, error in
            guard !completed else {
                return
            }

            completed = true

            if let error {
                continuation.resume(throwing: error)
            } else {
                continuation.resume(returning: success)
            }
        }
    }
}
Tagged:

Answers

  • Just copy and pasted that code block into the Login Kit test app, and I'm not able to repro - it's just getting called once. Is it possible the login method is being called twice?

  • It's not reproducible 100%, I don't know what are the exact steps. But most probably there is some corner case in code where it's possible that completion is called twice. I'd suggest just to review that part of the code on the SCSDKLoginClient side