Warning: touchID deprecated in iOS 11.0

Viewed 1244

I'm supporting Touch ID and Face ID within my app. To support older versions of iOS I'm using the following code:

if #available(iOS 11.0, *) {
    biometricsNotEnrolled = LAError.biometryNotEnrolled
    biometricsLocked = LAError.biometryLockout
} else {
    biometricsNotEnrolled = LAError.touchIDNotEnrolled
    biometricsLocked = LAError.touchIDLockout
}

switch(error) {
case biometricsNotEnrolled:
    // Do stuff
case LAError.passcodeNotSet:
    // Do stuff
case biometricsLocked:
    // Do stuff
default:
    // Do stuff
}

But when I compile I will get the following warnings:

warning: 'touchIDLockout' was deprecated in iOS 11.0: use LAErrorBiometryLockout

warning: 'touchIDNotEnrolled' was deprecated in iOS 11.0: use LAErrorBiometryNotEnrolled

warning: 'touchIDNotAvailable' was deprecated in iOS 11.0: use LAErrorBiometryNotAvailable

How can I get rid of the warning?

2 Answers

Your project or target version can solve this problem.

Here are tested you code in both versions - iOS 11.x & iOS 10.x

If your project target version is iOS 11+ then it will show your this warning as according Apple Document for LAError.Code, these values are deprecated in iOS 11.0.


Test Result - iOS 11.x

enter image description here


Test Result - iOS 10.x

enter image description here

When you are setting deployment target of some iOS version, deprecate message will show for that version, in this case its for iOS 11, lower the deployment target will stop showing the warning.

Related