1

我正在为 IAP 使用RMStore库(基于订阅),但在这一行出现异常: [[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];
}

相同的代码适用于示例应用程序,但不适用于我的应用程序。

4

1 回答 1

1

我注意到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 来持久化事务,并且当您刷新或调用收据时,它将根据RMStore 的文档自动持久化。在链接的页面末尾检查。

于 2017-03-10T11:53:29.967 回答