RMStore requestProducts在请求产品时提供exception
我正在使用RMStore库进行IAP(基于订阅),我在此行获得exception:[[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函数,exception在行:[_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进行事务的持久性,并且当您刷新或调用收据时,它将根据RMStore的文档自动保留 。 请在页面末尾的链接处查看。