Different fingerprints using Touch ID in ios [duplicate] - ios

This question already has answers here:
How can I differentiate between fingerprints with TOUCH ID [duplicate]
(1 answer)
Know which user logging into app depending on touchid in iOS
(1 answer)
Closed 5 years ago.
I am working on an application which uses Touch ID. I have integrated the Touch ID into the app to authenticate the user to access some app elements and it works fine.
LAContext *context = [[LAContext alloc] init];
NSError *error = nil;
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:#"Are you the device owner?" reply:^(BOOL success, NSError *error) {
if (error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:#"There was a problem verifying your identity."
delegate:nil
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
return;
}
NSLog(#"%#",context);
if (success) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Success"
message:#"You are the device owner!"
delegate:nil
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:#"You are not the device owner."
delegate:nil
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
}
}];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:#"Your device cannot authenticate using TouchID."
delegate:nil
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
}
Now, suppose if there are 2 fingerprints like Alice and Bob. Authentication works for both the fingerprints without any issue.
But I need to show which fingerprint user has been authenticated.
Is there any way to access it?

How would you even know which user is which? They don't have names, and there's no identity management substrate built into iOS.
You just have to trust that if the person who has added fingerprints is trusting someone else by adding their fingerprint, they gain access to everything TouchID authorizes.

Related

TouchID : How to get touch id authentication attempts?

I need to implement touch ID and have to show alert to user for authentication attempts left. Below code Im using.
reply block not getting called after one wrong authentication attempt. Its getting called after 3 continues wrong authentication attempt. Is there any way to get count of wrong authentication attempts..?
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = #"Touch ID Test to show Touch ID working in a custom app";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
dispatch_async(dispatch_get_main_queue(), ^{
[self performSegueWithIdentifier:#"Success" sender:nil];
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Error"
message:error.description
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles:nil, nil];
[alertView show];
NSLog(#"Switch to fall back authentication - ie, display a keypad or password entry box");
});
}
}];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Error"
message:authError.description
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles:nil, nil];
[alertView show];
});
}
I went through the documentation, it is not possible to show alert in each failed attempt. Just refer the documentation
LocalAuthentication in iOS. You can show alerts at different error cases. After 3rd failed attempt LAError.authenticationFailed will be called and after 5th failed attempt LAError.touchIDLockout will be called. You can display the alerts here. For more info refer Apple LAError documentation.

Check If Tweet with ID Has Been Retweeted

I have an app that shows tweets on a map and when one is selected it shows more details for the tweet (twitter handle, the tweet, profile pic, etc.) There are buttons for favoriting and retweeting the tweet. The app uses STTwitter to interact with the Twitter API and authenticates the user of the app with twitter = [STTwitterAPI twitterAPIOSWithFirstAccount]; For retweeting and favoriting in the tweet detail view, I do this:
- (IBAction)retweet:(id)sender {
[twitter postStatusRetweetWithID:tweetID successBlock:^(NSDictionary *status) {
UIAlertView *retweetSuccess = [[UIAlertView alloc]initWithTitle:#"Retweeted!" message:#"You have retweeted this post." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[retweetSuccess show];
} errorBlock:^(NSError *error) {
UIAlertView *retweetFailure = [[UIAlertView alloc]initWithTitle:#"Retweet Failed!" message:#"" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[retweetFailure show];
}];
}
- (IBAction)favorite:(id)sender {
[twitter postFavoriteCreateWithStatusID:tweetID includeEntities:nil successBlock:^(NSDictionary *status) {
UIAlertView *favoriteSuccess = [[UIAlertView alloc]initWithTitle:#"Favorited!" message:#"You have favorited this post." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[favoriteSuccess show];
} errorBlock:^(NSError *error) {
UIAlertView *favoriteFailure = [[UIAlertView alloc]initWithTitle:#"Favorite Failed!" message:#"" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[favoriteFailure show];
}];
}
How can I detect if a tweet has already been retweeted or favorited by the user so I can show a different button image for the retweet and favorite buttons?

UIAlert not showing

Fresh and green newbie here. I just started programming and already got stuck with UIAlert. I've searched on this site but there are so many postings and as I said I am kinda new to all this so I don't know what to really look for. This is what I have.
-(void)showError {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:#"Please try again later. Have a nice day."
delegate:nil
cancelButtonTitle:#"Dismiss"
otherButtonTitles:nil];
}
Need to do
[alert show];
to present
Code should be :
-(void)showError {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:#"Please try again later. Have a nice day."
delegate:nil
cancelButtonTitle:#"Dismiss"
otherButtonTitles:nil];
[alert show];
[alert release];
}
[alert show];
I always forget this too. Happy Coding.
-(void)showError
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:#"Please try again later. Have a nice day."
delegate:nil
cancelButtonTitle:#"Dismiss"
otherButtonTitles:nil];
[alert show];
}

Checking to see if textfields are filled out

In my Calorie Tracker App, I have two textfields. One is for the name of the food, and the other is for the amount of calories.To check and see if they are filled I wrote the following code:
if([foodString isEqual: #" "])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Warning!" message:#"You have not entered the name of the meal!" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
}
else if([self.amountText isEqual: #" "])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Warning!" message:#"You have not enteted the amount of calories!" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
}
else if([self.amountText isEqual:#" "] && [foodString isEqual:#" "])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Warning!" message:#"You haven't entered anything!" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
}
So for the one where the amountText textfield isn't filled out, but the nameOfFood is filled out, there is an alert. For the rest however, there is no alert. If anyone could provide the proper syntax for checking to see if my textfields are being filled out properly, it would be much appreciated.
Remember, my first textfield is a string value, and the other is an integer value.
Thanks in advance.

Why is Core Location manager not working on iOS 6 simulator (using OSX Mountain Lion)

I was following the Core Data tutorial for iOS from this link
and my location manager does not appear to be picking up any events. I enabled location services on the simulator and when I launch the app it asks for permission to use my location and I say "ok". Any idea why it's not picking anything up?
My location manager delegate method shown below returns the following error:
2013-02-15 18:05:16.653 Locations[8280:c07] errorError Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
I even tried Debug --> simulate location.
I am using OSX Mountain Lion btw.
Thanks!
//location manager delegate method for fail
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error {
NSLog(#"Reached loc mngr delegate method 2...error occurred");
[manager stopUpdatingLocation];
NSLog(#"error%#",error);
switch([error code])
{
case kCLErrorNetwork: // general, network-related error
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"please check your network connection or that you are not in airplane mode" delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
}
break;
case kCLErrorDenied:{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"user has denied to use current Location " delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
}
break;
default:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"unknown network error" delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
}
break;
}
addButton.enabled = NO;
}

Resources