我使用这些代码在swift3中使用xcode 8.2.1中的结构数字进行短信验证。
let authButton = DGTAuthenticateButton(authenticationCompletion: { (session, error) in
if (session != nil) {
let message = "Phone number: \(session!.phoneNumber)"
let alertController = UIAlertController(title: "You are logged in!", message: message, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: .none))
self.present(alertController, animated: true, completion: .none)
} else {
NSLog("Authentication error: %@", error!.localizedDescription)
}
})
authButton?.center = self.view.center
self.view.addSubview(authButton!)
答案 0 :(得分:0)
根据此https://docs.fabric.io/apple/digits/advanced-setup.html#verifying-a-user,您需要添加:
Digits.sharedInstance()。start(withConsumerKey:“Your API Key”,consumerSecret:“Your Secret Key”)
之前
Fabric.with([Digits.self])
在AppDelegate.swift文件中
这解决了我的问题