我使用这些代码在 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!)