How to add "Touch Id" with "In app Purchase" in Objective c?
Asked Answered
T

1

6

I have successfully implemented "In App Purchase" in my project and now i am trying to implement a "Touch Id" to buy a product except asking a "Sign in to iTunes" popup. Here in my code it asks "touch id" and "Sign in to iTunes" popup both one after another, why this one wired both things i want only "touch id" to buy product. I have gone for IAP How do you add an in-app purchase to an iOS application? and for Touch ID How do i integrate Touch ID for my IAP? but not getting proper way to implement a touch id for IAP.Here is the code i have added,enter image description here

Is this possible through code or it shows apple at the time of buying a product from app store. Check above snapshot,

#import <LocalAuthentication/LocalAuthentication.h>

-(void) localAunthentication  
{
    //LocalAuthentication
    LAContext *authContext = [[LAContext alloc] init];
    NSError *authError = nil;
    NSString *authLocalizedReasonString = @"Please aunthenticate to proceed";

    if ([authContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError])
    {
        [authContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
                    localizedReason:authLocalizedReasonString
                              reply:^(BOOL success, NSError *error)
         {
             if (success)
             {
                 // Allocated here for succinctness.
                 NSOperationQueue *operationQueue = [[NSOperationQueue alloc] init];


                 [operationQueue addOperationWithBlock: ^
                  {


                  }];
             }
             else
             {
                 switch (error.code)
                 {
                     case LAErrorAuthenticationFailed:
                         //Authentication Failed
                         break;

                     case LAErrorUserCancel:



                         break;

                     case LAErrorUserFallback:


                         break;

                     default:
                         //Touch ID is not configured
                         break;
                 }
                 NSLog(@"%@",error.localizedDescription);

             }
         }];
    }
    else
    {
    }
}

What should i do to asks only "Touch Id" instead of "Sign in To iTunes" popup.

Thirst answered 15/3, 2018 at 13:59 Comment(0)
G
12

The iTunes Store controls what kind of authentication it presents, not your app. If necessary, an alert will be presented, otherwise the TouchID/FaceID overlay.

The reason you're never seeing the TouchID/FaceID overlay is that during development, your app is not using the real iTunes Store but a sandbox. The sandbox environment, AFAIK, always presents an alert.

Grajeda answered 15/3, 2018 at 17:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.