gpt4 book ai didi

ios - RMStore离线收货验证

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:46:08 25 4
gpt4 key购买 nike

关于使用RMStore ( https://github.com/robotmedia/RMStore ) 进行离线收据验证的一个问题

在应用程序启动时,我检查该应用程序是否具有有效的应用程序内购买(专业版)(我的应用程序只有 iOS7)

我是这样做的:

RMStoreAppReceiptVerificator *verificator = [[RMStoreAppReceiptVerificator alloc] init];
BOOL isValidReceipt = [verificator verifyAppReceipt];
if (isValidReceipt)
{
BOOL isProVersion = [[RMAppReceipt bundleReceipt] containsInAppPurchaseOfProductIdentifier:xxx];
...
}

我在 App Store 中还有 1.0 版本...但现在我想尽快进行更新...这在应用商店更新后仍然有效,对吗? App 中仍会有收据,验证应该仍会通过,对吧?

我之所以问是因为测试应用内购买并不是一件容易的事(尤其是更新之类的),如果出现问题,用户会很生气....

最佳答案

代码应该像以前一样工作。但是,您没有正确验证收据。引用 Receipt Validation Programming Guide :

If validation fails in iOS, use the SKReceiptRefreshRequest class to refresh the receipt.

使用 RMStore,看起来像这样:

const BOOL verified = [self verifyReceiptWithCustomLogic];
if (verified)
{
// Verification succeeded
}
else
{ // Apple recommends to refresh the receipt if validation fails on iOS
[[RMStore defaultStore] refreshReceiptOnSuccess:^{
const BOOL verified = [self verifyReceiptWithCustomLogic];
if (verified)
{
// Verification succeeded
}
else
{
// Verification failed
}
} failure:^(NSError *error) {
// Verification failed
}];
}

您的验证逻辑出现的位置:

- (BOOL)verifyReceiptWithCustomLogic
{
RMStoreAppReceiptVerificator *verificator = [RMStoreAppReceiptVerificator new];
if ([verificator verifyAppReceipt])
{
return [[RMAppReceipt bundleReceipt] containsInAppPurchaseOfProductIdentifier:xxx];
}
return NO;
}

请注意,刷新收据会使收据验证成为一个异步过程。

关于ios - RMStore离线收货验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23786157/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com