使用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版...但是现在我想尽快进行更新...这在应用商店更新后仍然有用,对吧?该应用程序仍然会有收据,验证仍然应该通过,对吗?
我问,因为测试应用内购买并不容易(尤其是更新和内容),如果出现问题,用户会感到生气....
答案 0 :(得分:4)
代码应该像以前一样工作。但是,您未正确验证收据。引用Receipt Validation Programming Guide:
如果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;
}
请注意,刷新收据会使收据验证成为异步过程。