2

We are using sinch verification by pods with swift 3.0 and xcode 8.0 . I want to call initiate() and verifyCode() methods but compiler show value of type SINVerification? has no member I have import import SinchVerificationand written below code :-

let region:String = SINDeviceRegion.currentCountryCode()
        let phoneNumber:SINPhoneNumber?
        do {

             try phoneNumber = SINPhoneNumberUtil().parse("xxxxxxxxxx", defaultRegion: region)

            let phoneNumberInE164:String = SINPhoneNumberUtil().formatNumber(phoneNumber!, format: SINPhoneNumberFormat.E164)
           let verification = SINVerification.smsVerification(withApplicationKey: "965010f3-bb37-4356-82ba-fea0452377d9", phoneNumber: phoneNumberInE164) as? SINVerification
            verification.initiate { (success:Bool, error:Error?) -> Void in
                //handle outcome
                if (success){
                    print("successfully requested phone verification")

                } else {

                    print(error?.localizedDescription)

                }
            }
Vinod Kumar
  • 3,375
  • 1
  • 17
  • 35

1 Answers1

1

it should look like this

  let verification = SMSVerification(applicationKey:"<APP KEY>", phoneNumber: phoneNumberInE164)
    verification.initiate { (result: InitiationResult, error: NSError?) -> Void in
        // handle outcome
    }    

Not sure why cast to SINVerification, but i think the error is that you have result as a bool but its a InitiationResult

cjensen
  • 2,703
  • 1
  • 16
  • 15
  • What do you mean? – cjensen Feb 03 '17 at 23:38
  • I am using 2.0.3 version of sinch – Vinod Kumar Feb 04 '17 at 05:00
  • `let verification = SMSVerification(applicationKey:applicationKey, phoneNumber: phoneNumberInE164)` **//this line show error :- "use of unresolved identifier 'SMSVerfication' "** `verification.initiate { (result: InitiationResult, error: NSError?) -> Void in` **// this line show error :- "use of undeclared type 'initiationResult' "** // handle outcome `}` @cjensen – Vinod Kumar Feb 04 '17 at 05:17