0

I have been converting my code to swift 3. I have an issue with since verification:

This is the code I have:

verification.initiate { (success:Bool, error:Error?) -> Void in
            //handle outcome
            if (success){
                print("successfully requested phone verification")
                //segue to next screen
                self.performSegue(withIdentifier: "xxx", sender: nil)
            } else {
                let alert = UIAlertController(title: "Alert", message: error?.localizedDescription, preferredStyle: .alert)
                alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
                self.present(alert, animated: true, completion: nil)
                print(error?.localizedDescription)
                self.buttonsEnable(true)
            }
}

Xcode is returning the following error:

Cannot convert value of type '(Bool, Error?) -> Void' to expected argument type '(InitiationResult, Error?) -> Void'

Any ideas on how to fix this? I have updated to the latest version of the sdk.

Nik F
  • 71
  • 1
  • 11

1 Answers1

1

The error pretty much tells you what the problem is. The completion block has to be of type

(InitiationResult, Error?) -> Void

instead of

(Bool, Error?) -> Void

So you should be able to do:

verification.initiate { (result:InitiationResult, error:Error?) -> Void in

and then check the success with

if result.success { ... }
Keiwan
  • 8,031
  • 5
  • 36
  • 49