SKReceiptRefreshRequest每次询问密码 [英] SKReceiptRefreshRequest asking password everytime
问题描述
我正在使用 SKReceiptRefreshRequest
来验证来自服务器的收据.问题是每次密码提示时我都会问我.谁能帮我推荐一个更好的验证用户收据的方法
I am using SKReceiptRefreshRequest
to validate the receipt from the server. The problem is it is asking me every time password prompt. Can anyone help suggest me a better way to validate the user receipt
这就是我正在做的事情(应用启动时我正在使用 refreshReceipt
)
Here's what I am doing (i am using refreshReceipt
when the app starts)
- (void)refreshReceipt {
SKReceiptRefreshRequest *refresh = [[SKReceiptRefreshRequest alloc] initWithReceiptProperties:nil];
refresh.delegate = self;
[refresh start];
}
- (void)requestDidFinish:(SKRequest *)request API_AVAILABLE(ios(3.0), macos(10.7)) {
if ([request isKindOfClass:[SKReceiptRefreshRequest class]]) {
NSLog(@"Got a new receipt...");
[self verifyReceipt:self.loadingView :NO :^{
} :^{
[app_delegate jumpToLogin];
}];
}
}
- (void)verifyReceipt :(UIView *)view1 :(BOOL)showHUD : (void (^)(void)) complete : (void (^)(void)) incomplete
{
if (showHUD) {
[UtilityManager showHUD:view1];
}
/* Load the receipt from the app bundle. */
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
if (!receipt) {
/* No local receipt -- handle the error. */
[UtilityManager hideHUD:view1];
incomplete();
return;
}
/* Create the JSON object that describes the request */
NSError *error;
// Verify the recipt
推荐答案
在您的情况下,由于设备上缺少沙箱收据,因此要求输入密码.它正在尝试刷新现有收据,但找不到它.因此,它将获得一张新的收据,这就是为什么它要求输入密码的原因.
In your case it's asking for a password because sandbox receipt is missing on your device. It's trying to refresh existing receipt, but can't find it. So it's going to get a fresh receipt, that is why it's asking for a password.
在生产中(从App Store下载该应用程序时)总会有一张收据,因此不需要密码.
In production (when the app is downloaded from the App Store) there will always be a receipt, so it won't require a password.
为什么要使用 SKReceiptRefreshRequest
?只有恢复购买"按钮才需要.
And why are you using SKReceiptRefreshRequest
? It's only required for "Restore purchases" button.
以下是我们博客中的文章: https://blog.apphud.com/receipt-validation/
Here is article from our blog: https://blog.apphud.com/receipt-validation/
这篇关于SKReceiptRefreshRequest每次询问密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!