ios - RMStore requestProducts 在请求产品时给出异常

标签 ios objective-c in-app-purchase rmstore

我正在使用 RMStore IAP 库(基于订阅),我在这一行得到异常:[[RMStore defaultStore] requestProducts:[NSSet setWithArray:_products] success:^(NSArray *products, NSArray *invalidProductIdentifiers) {

- (void)viewDidLoad
{
[super viewDidLoad];
_products = @[@"NEWSUB01",
              @"NEWSUB06",
              @"NEWSUB12"];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[[RMStore defaultStore] requestProducts:[NSSet setWithArray:_products] success:^(NSArray *products, NSArray *invalidProductIdentifiers) {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    _productsRequestFinished = YES;


} failure:^(NSError *error) {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Products Request Failed", @"")
                                                        message:error.localizedDescription
                                                       delegate:nil
                                              cancelButtonTitle:NSLocalizedString(@"OK", @"")
                                              otherButtonTitles:nil];
    [alertView show];
}];
}

下面是 requestProducts 函数,异常在行:[_productsRequestDelegates addObject:delegate];

- (void)requestProducts:(NSSet*)identifiers
            success:(RMSKProductsRequestSuccessBlock)successBlock
            failure:(RMSKProductsRequestFailureBlock)failureBlock
{
RMProductsRequestDelegate *delegate = [[RMProductsRequestDelegate alloc] init];
delegate.store = self;
delegate.successBlock = successBlock;
delegate.failureBlock = failureBlock;
[_productsRequestDelegates addObject:delegate];

SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:identifiers];
productsRequest.delegate = delegate;

[productsRequest start];
}

相同的代码在示例应用程序中有效,但在我的应用程序中无效。

最佳答案

有一件事我注意到 RMStore 中的示例项目正在使用不可再生的 IAP。对于基于自动续订订阅的 IAP,您应该按如下方式设置您的商店:

const BOOL iOS7OrHigher = floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1;
_receiptVerifier = iOS7OrHigher ? [[RMStoreAppReceiptVerifier alloc] init] : [[RMStoreTransactionReceiptVerifier alloc] init];
[RMStore defaultStore].receiptVerifier = _receiptVerifier;


_persistence = [[RMStoreUserDefaultsPersistence alloc] init];
[RMStore defaultStore].transactionPersistor = _persistence;

使用 RMStoreUserDefaultsPersistence 来持久化事务,并且当您刷新或调用收据时,它将根据 documentation of RMStore 自动持久化。 .检查页面末尾的链接。

关于ios - RMStore requestProducts 在请求产品时给出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42433636/

相关文章:

ios - 是否可以通过在实时应用程序中验证收据来获取 21007 状态码?

ios - 从 nib 自定义 UiTableViewCell 而不重用?

ios - 发送到实例的 UICollectionViewCell 无法识别的选择器

iphone - 我可以从沙盒 AppStore 中删除对非消耗品的购买吗?

iphone - iOS注销设计

ios - 将一个单独的文件转换为 arc

android - 无法测试应用内订阅

ios - 状态栏下的 Swift 导航栏

cocoa-touch - 如何根据 ASIHTTPRequest 执行不同的操作?

iPhone 自定义 UI 设计和构建资源