1

Hi I implement the sms verification following SINCH tuto:

 verification.verify(enterPin.text!,
                            completion: { (success:Bool, error:NSError?) -> Void in
                                self.spinner.stopAnimating();
                                self.verifyButton.enabled = true;
                                self.enterPin.enabled = true;
                                if (success) {
                                    //here I want to get the phone number in theE164 Format
                                    self.status.text = "Verified";                        

                                } else {
                                    self.status.text = error?.description;
                                }
        });

I want to retrieve the phone number in the E164 FORMAT if the verification succeeded.. thanks for your help!

jerem
  • 1,016
  • 2
  • 12
  • 27

2 Answers2

1

Use this library

and then use this call:

let formattedString: String = try phoneUtil.format(phoneNumber, numberFormat: .E164)
Marco Santarossa
  • 4,058
  • 1
  • 29
  • 49
  • thanks for answering , but I suppose that SINCH manage to do the same work , after the phoneNumber is verified (success == true in my example) , I want to get the phoneNumber in the format they used – jerem Aug 19 '16 at 15:47
  • Ok, look at this: https://www.sinch.com/docs/verification/ios/#phonenumbers they have a SINPhoneNumberUtil to format the number and I think that under the hood they use the library I wrote – Marco Santarossa Aug 19 '16 at 17:19
1

There is a phone number formatter included in the sinch SDK, however the phonenumber is not returned in the result, you should format the number e164 with the formatter even before you send it to sinch. If you ave a new view for entering the code, just pass the number over to that view when you do the transition.

cjensen
  • 2,703
  • 1
  • 16
  • 15