我已经在我的项目中成功实现了“In App Purchase”,现在我正在尝试实现“Touch Id”来购买产品,除了询问“登录 iTunes”弹出窗口。在我的代码中,它一个接一个地询问“touch id”和“登录 iTunes”弹出窗口,为什么这个连接这两个东西我只想要“touch id”来购买产品。我去IAP了How do you add an in-app purchase to an iOS application?和 Touch ID How do i integrate Touch ID for my IAP?但没有找到为 IAP 实现触摸 ID 的正确方法。这是我添加的代码,
这是否可以通过代码实现,或者在从应用商店购买产品时显示苹果。 检查上面的快照,
#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
{
}
}
我应该怎么做才能只询问“Touch Id”而不是“登录 iTunes”弹出窗口。
最佳答案
iTunes Store 控制它提供的身份验证类型,而不是您的应用程序。如有必要,将显示警报,否则会显示 TouchID/FaceID 覆盖。
您从未看到 TouchID/FaceID 叠加层的原因是,在开发过程中,您的应用程序使用的不是真正的 iTunes Store,而是沙盒。沙箱环境 AFAIK 始终显示警报。
关于ios - 如何在 Objective c 中添加 "Touch Id"和 "In app Purchase"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49301450/