我在用SKReceiptRefreshRequest
验证来自服务器的收据。问题是每次提示密码时它都会询问我。谁能帮我建议一种更好的方法来验证用户收据
这就是我正在做的事情(我正在使用refreshReceipt
当应用程序启动时)
- (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
在您的情况下,它要求输入密码,因为您的设备上缺少沙箱收据。它正在尝试刷新现有收据,但找不到它。因此它将获得新的收据,这就是它要求输入密码的原因。
在生产环境中(当从 App Store 下载应用程序时)总会有一张收据,因此不需要密码。
你为什么使用SKReceiptRefreshRequest
?仅“恢复购买”按钮需要它。
这是我们博客上的文章:https://blog.apphud.com/receipt-validation/ https://blog.apphud.com/receipt-validation/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)