Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sign in with apple button not firing target function

I have an app with a min target of iOS 11. However, I need to support Sign In With Apple, so I'm adding a sign in with apple button to my stack view like this:

private var appleButton: UIControl 
    // Has to be a UIControl because ASAuthorizationAppleIDButton not supported in <iOS 13

private func setupAppleSignIn() {
    guard #available(iOS 13, *) else {
        return
    }

    let button = ASAuthorizationAppleIDButton(
        authorizationButtonType: .signIn,
        authorizationButtonStyle: .white
    )
    button.cornerRadius = button.bounds.height/2
    stackView.insertArrangedSubview(button, at: 0)

    button.addTarget(self, action: #selector(handleSignInWithApple), for: .touchUpInside)
    appleButton = button
}

@objc
func handleSignInWithApple() {
    print("fired")
}

This successfully adds the button to my stackview. However, when I tap it, it doesn't fire my handleSignInWithApple function. Why?

UPDATE

It's only firing if I drag my finger a bit and release it. If I just tap, it doesn't work! Why?

like image 291
Tometoyou Avatar asked Jul 20 '20 21:07

Tometoyou


People also ask

Why cant I use Sign in with Apple?

If you get a message that your Apple ID is locked or disabled. If you or someone else enters your password, security questions, or other account information incorrectly too many times, your Apple ID automatically locks to protect your security and you can't sign in to any Apple services.

How do I enable Sign in with Apple?

Go to Settings > Passwords. Under Security Recommendations, tap an app or website name. * Tap Use Sign in with Apple, then follow the onscreen steps.

Does Sign in with Apple work on simulator?

Apple Sign-in doesn't work with ios-14 simulator in Xcode 12.

Why can my Apple ID not be used to create accounts for other apps?

If you can't use your Apple ID to create an account for a new app, make sure “Sign in with Apple” is supported. This feature is not available for children under 13. Log out of your Apple account on all your devices, restart them, and sign back in. If the issue persists, reset all your iOS settings.


1 Answers

Turns out it was a bug in Xcode that has since been fixed. Just update Xcode if you're having this problem, or add a UITapGestureRecognizer on the button!

like image 128
Tometoyou Avatar answered Oct 10 '22 09:10

Tometoyou