gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 11:48:05 24 4
gpt4 key购买 nike

我正在使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com