Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
333 views
in Technique[技术] by (71.8m points)

ios - Is it possible to add ASAuthorizationAppleIDButton as a UIAlertAction?

I have a UIAlert that I use to redirect users to Gmail Firebase login. Now I want to add support for Sign In With Apple. But I read in multiple locations that you have to set up the button this way:

let siwaButton = ASAuthorizationAppleIDButton()

siwaButton.addTarget(self, action: #selector(appleSignInTapped), for: .touchUpInside)

@objc func appleSignInTapped() {
    let provider = ASAuthorizationAppleIDProvider()
    let request = provider.createRequest()
    // request full name and email from the user's Apple ID
    request.requestedScopes = [.fullName, .email]

    // pass the request to the initializer of the controller
    let authController = ASAuthorizationController(authorizationRequests: [request])
  
    // similar to delegate, this will ask the view controller
    // which window to present the ASAuthorizationController
    authController.presentationContextProvider = self
  
    // delegate functions will be called when user data is
    // successfully retrieved or error occured
    authController.delegate = self
    
    // show the Sign-in with Apple dialog
    authController.performRequests()
}

Would it be possible to add this button to the following UIAlertView? If not, is there a pod out there that makes it easy to present a menu of sign options?

let preSignInAlert = UIAlertController(title: "Discussions", message: preLoginInfoMessage, preferredStyle: .alert)
let dismissAction = UIAlertAction(title: "Okay", style: .cancel) { _ in }
let loginAction = UIAlertAction(title: "Login", style: .default) { (alert) in
    GIDSignIn.sharedInstance()?.signIn()
}

// Space for a third Apple Login button

preSignInAlert.addAction(dismissAction)
preSignInAlert.addAction(loginAction)
present(preSignInAlert, animated: true, completion: nil)
question from:https://stackoverflow.com/questions/65862589/is-it-possible-to-add-asauthorizationappleidbutton-as-a-uialertaction

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...