Error: No exact matches in reference to static method 'buildExpression'

Hello everyone, I'm just getting started with Swift and I'm in a bit of a knot here. Code below:

`if codeSent { TextField("6 Digit Code", text: $code)

                Divider()
                
                Button("Verify") {
                    print("verify...")
                    
                    if code.count == 6 {
                        cloud(fun: "customSmsAuth", cloudData: [
                            "code": code,
                            "phoneNumber": phoneNumber
                        ], completion: { resData in
                            let res = resData["res"] as? Int
                            
                            if res == 1 {
                                let customToken = resData["customToken"]
                                
                                Auth.auth().signIn(withCustomToken: customToken) { user, error in
                                    
                                    
                                }
                            } else {
                                print("An error occured...")
                            }
                        })
                    } else {
                        print("invalid code...")
                    }
                }.padding()
            }`

`else { HStack { Button("+26") { print("phone code...") }

                    TextField("Phone Number", text: $phoneNumber)
                }
                
                Divider()
                
                Button("Send Code") {
                    print("send code...")
                    
                    if phoneNumber.count == 10 {
                        cloud(fun: "sendSms", cloudData: ["phoneNumber" : "+26"+phoneNumber], completion: { resData in
                            let res = resData["res"] as? Int
                            
                            if res == 1 {
                                codeSent = true
                            } else {
                                print("An error occured...")
                            }
                        })
                    } else {
                        print("Invalid phone number...")
                    }
                    
                    print(phoneNumber)
                }.padding()
            }`

I'm trying to setup a simple phone based authentication with firebase. Any pointer where I'm going wrong will be appreciated.

Thanks.

  • Please note that the code works just fine without lines 43 to 46.

Add a Comment

Accepted Reply

Please show complete code.

Where and how is customToken defined ? Is it an optional ?

If optional String, call should probably be:

Auth.auth().signIn(withCustomToken: customToken ?? "") { user, error in
  // some code
}
  • @Claude31 that solved it. I simply changed ** let customToken = resData["customToken"]**

    to ** let customToken = resData["customToken"] as? String**

    Thanks for your help.

Add a Comment

Replies

Please show complete code.

Where and how is customToken defined ? Is it an optional ?

If optional String, call should probably be:

Auth.auth().signIn(withCustomToken: customToken ?? "") { user, error in
  // some code
}
  • @Claude31 that solved it. I simply changed ** let customToken = resData["customToken"]**

    to ** let customToken = resData["customToken"] as? String**

    Thanks for your help.

Add a Comment