iOS应用内购买无法正常工作

时间:2013-01-19 18:47:14

标签: ios in-app-purchase

基本上我试图让应用内购买工作,但没有运气。以下是我申请购买产品的代码

- (void)requestProductData
{
    NSSet *productIdentifiers=[NSSetsetWithObject:productid];
     request5= [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject: productIdentifiers]];
    request5.delegate = self;
    [request5 start];
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    myProducts = response.products;
    for (NSString *invalidProductId in response.invalidProductIdentifiers)
    {
        NSLog(@"Invalid product id: %@" , invalidProductId);
    }
    SKProduct *selectedProduct = [myProducts objectAtIndex:0];
    SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct];
    [[SKPaymentQueue defaultQueue] addPayment:payment];
}

奇怪的是,response.products和response.invalidProductId都有0个对象。我已经尝试过检查配置文件,appID,软件包ID等等。此外,自从我在itunes connect中添加了应用内购买后,差不多24小时了。任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

检查发出请求的代码。你有:

NSSet *productIdentifiers = [NSSet setWithObject:productid];
request5 = [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject: productIdentifiers]];

应该是:

NSSet *productIdentifiers = [NSSet setWithObject:productid];
request5 = [[SKProductsRequest alloc] initWithProductIdentifiers: productIdentifiers];

您正在创建一个包含一个对象的集合 - 另一个具有产品ID的集合。