在iphone应用程序中检索InApp购买产品列表的问题

时间:2011-07-22 09:58:57

标签: iphone objective-c cocoa-touch in-app-purchase

我使用下面的代码来检索产品列表

-(void) viewWillAppear:(BOOL)animated
{
    if ([SKPaymentQueue canMakePayments]) {
        NSLog(@"Parental-controls are disabled");

        //Request products.Retrieving list of products
        SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"com.test.SinFinder"]];
        productsRequest.delegate = self;
        [productsRequest start];
    } else {
        NSLog(@"Parental-controls are enabled");
    }
}


- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
    SKProduct *validProduct = nil;
    int count = [response.products count];
    NSLog(@"count : %d",count);
    if (count > 0) {
        validProduct = [response.products objectAtIndex:0];
    } else if (!validProduct) {
        NSLog(@"No products available");
    }    
}

在处理响应时,我计算为零,因此在updatedTransactions方法中,它会转到SKPaymentTransactionStateFailed并记录错误。 我不知道出了什么问题或者缺少什么 或者这是必要的,即产品列表,因为我只需要在购买应用后锁定功能

1 个答案:

答案 0 :(得分:1)