How to remove Enter Password and Cancel button from Touch ID alert view
Asked Answered
R

7

27

I got stuck that don't want Enter Password in the Alert of thumb impression

[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:NSLocalizedString(@"UNLOCK_ACCESS_TO_LOCKED_FEATURE", nil) reply:
         ^(BOOL success, NSError *authenticationError)
         {
             if (success)
             {

                 msg =[NSString stringWithFormat:NSLocalizedString(@"EVALUATE_POLICY_SUCCESS", nil)];
             }
             else
             {
                 msg = [NSString stringWithFormat:NSLocalizedString(@"EVALUATE_POLICY_WITH_ERROR", nil), authenticationError.localizedDescription];
             }
         }];
     }
Revisal answered 23/1, 2015 at 5:27 Comment(2)
You should really leave that option there. What if a user doesn't have Touch ID set up.Fireresistant
if a user doesn't have Touch ID set up that time alert will not appear.Revisal
P
71

To hide the button "Enter password", you need to set localizedFallbackTitle to an empty string.

//...
LAContext *context = [[LAContext alloc] init];

// Hide "Enter Password" button
context.localizedFallbackTitle = @"";

// show the authentication UI
//...

About the "Cancel" button I don't think that it is possible to remove it.

Hope that it will be helpful.

Plasmolysis answered 26/1, 2015 at 18:8 Comment(1)
i have also did the same it worked...but still i m trying for cancel button.Revisal
V
15

There is localizedFallbackTitle property of LAContext class. If you want custom text instead of “Enter password” then you can set here.

If it is set to empty string then the button will be hidden.

Screenshot 1

Below is code that I’ve used :

 //MARK: - scanFingerPrint
    func scanFingerPrint() {
        let authContext:LAContext = LAContext()
        authContext.localizedFallbackTitle = ""
    . . .
    }

Screenshot 2

Veats answered 14/9, 2016 at 11:19 Comment(0)
G
4

Look at LAContext.h, I found this:

/// Fallback button title.
/// @discussion Allows fallback button title customization. A default title "Enter Password" is used when
///             this property is left nil. If set to empty string, the button will be hidden.
@property (nonatomic, copy) NSString *localizedFallbackTitle;

You should set localizedFallbackTitle = @"" -- empty string;. Let's try it and accept answer if it work.

Greataunt answered 23/1, 2015 at 7:8 Comment(0)
M
1

You should used empty string like "" for localizedFallbackTitle
Example:

let context:LAContext = LAContext()
context.localizedFallbackTitle = ""
Malediction answered 9/9, 2021 at 7:44 Comment(1)
Please add further details to expand on your answer, such as working code or documentation citations.Cawthon
S
0

You can remove "cancel" button, however your app will be rejected in this case

[context setCancelButtonVisible:false];
Smallclothes answered 12/2, 2015 at 11:21 Comment(1)
Why would you add an option (after acceptable, Apple-designated/approved options have been offered) that violates the HIG?Mayonnaise
N
0

Looks like Apple has added a way to cusotmize the cancel button title from iOS 10,

localizedCancelTitle

The localized title for the fallback button in the dialog presented to the user during authentication.

Discussion

This string should be provided in the user’s current language and should be short and clear.

https://developer.apple.com/documentation/localauthentication/lacontext/1643658-localizedcanceltitle

Nedanedda answered 24/1, 2018 at 9:52 Comment(0)
F
0

you can change the title of cancel button if you like

[context setLocalizedCancelTitle:@"ABC"];
Figural answered 5/1, 2021 at 15:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.