Reputation: 3385
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 SinchVerification
and 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)
}
}
Upvotes: 2
Views: 303
Reputation: 2703
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
Upvotes: 1