3

关于离线收据验证的一个问题RMStorehttps://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 Store 更新后仍然有效,对吧?该应用程序仍然会有收据,并且验证应该仍然通过,对吧?

我问是因为测试应用内购买并不容易(尤其是更新和东西),如果出现问题,用户会很生气....

4

1 回答 1

4

代码应该像以前一样工作。但是,您没有正确验证收据。引用收据验证编程指南

如果在 iOS 中验证失败,请使用SKReceiptRefreshRequest该类刷新收据。

使用 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;
}

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

于 2014-05-21T14:48:23.537 回答