Swift Firebase authentication not working when in another class

前端 未结 1 856
长情又很酷
长情又很酷 2021-01-28 12:53

I am attempting a project just for fun, I would like to use Firebase. I made a class to user for user related things. I was testing the signing up function and when it is within

相关标签:
1条回答
  • 2021-01-28 13:06

    Your issue is that the createUser method is asynchronous. You are returning made from your function before createUser finishes.

    func createAccount()-> Bool {...}

    should be

    func createAccount(completion: (Bool)->Void) {...}

    And then when the Firebase Auth call to createUser completes, you call completion(made).

    You will need to read up on asynchronous calls in programming and closures in swift to understand better. You can start with something like this article.

    0 讨论(0)
提交回复
热议问题