我想在我的iOS应用程序中实现本地身份验证安全性但是我收到错误而无法弄清楚我为什么会这样做.
我正在使用iPhone 5s.这有关系吗?
码:
import UIKit
import LocalAuthentication
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func action(_ sender: Any) {
authenticateUser()
}
func authenticateUser() {
let authContext : LAContext = LAContext()
var error: NSError?
if authContext.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: &error){
authContext.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, localizedReason: "Biometric Check for application", reply: {(successful: Bool, error: …
Run Code Online (Sandbox Code Playgroud) 我们已经在应用程序中使用Google登录了。我们在请求登录时提供了serverClientID。
我们将user.serverAuthCode设置为nil。
我们的要求如下:
func googleLogin(){
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
let gid = GIDSignIn.sharedInstance()
if let path = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist") {
let myDict = NSDictionary(contentsOfFile: path)
gid?.serverClientID = "our servers cliet id as configured over firebase"
// This client id of our ios app we are getting from
// GoogleService-info.plist
gid?.clientID = myDict!.value(forKey: "CLIENT_ID") as! String
}
// gid?.serverClientID = "our_servers" // TODO: fetch from plist
gid?.scopes.append("https://www.googleapis.com/auth/gmail.readonly")
print("\nClient Id: \(gid!.clientID!) Server …
Run Code Online (Sandbox Code Playgroud)