RMStore requestProducts在请求产品时提供异常 [英] RMStore requestProducts gives exception when requesting products

查看:571
本文介绍了RMStore requestProducts在请求产品时提供异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using RMStore library for IAP (subscription based) and I get exception at this line: [[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:委托];

below is the requestProducts function and the exception is at line: [_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];
}

相同的代码适用于示例应用,但在我的应用中不起作用。

Same code works in a sample app but does not work in my app.

推荐答案

有一点我注意到 RMStore 正在使用不可再生的IAP。对于基于IAP的自动续订订阅,您应将商店设置如下:

One thing I noticed that the sample project in RMStore is using non-renewable IAP. For auto-renewable subscription based IAP you should set your store as below:

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进行交易持久性,当您刷新或调用收据时,它将自动保留到 RMStore的文档。请在页面末尾的链接处查看。

Use RMStoreUserDefaultsPersistence for persistence of transaction and also when you refresh or call the receipt it will be persisted automatically according to the documentation of RMStore. Check at the end of the page at the link.

这篇关于RMStore requestProducts在请求产品时提供异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆