如何为iTunes配置应用内购买?

时间:2012-01-24 11:23:01

标签: ios in-app-purchase

如何为应用内购买配置iTunes Connect? 我在iTunes Connect中添加了产品,但在response.product中,它总是返回一个空值。

- (void)requestProducts {
    NSSet *productIdentifiers = [NSSet setWithObject:@"com.classic.caddycommonground.t1" ];
    //NSLog(@"product identifier %@",_productIdentifiers);
    self.request = [[[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers] autorelease];
    _request.delegate = self;
    [_request start];
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {

    NSArray *items = response.products;

    for(SKProduct *item in items)
    {
        NSLog(@"Product title: %@" , item.localizedTitle);
        NSLog(@"Product description: %@" , item.localizedDescription);
        NSLog(@"Product price: %@" , item.price);
        NSLog(@"Product id: %@" , item.productIdentifier);
    }

    /*
    for (NSString *invalidProductId in response.invalidProductIdentifiers)
    {
        NSLog(@"Invalid Product title: %@" , items.localizedTitle);
        NSLog(@"Invalid Product description: %@" , items.localizedDescription);
        NSLog(@"Invalid Product price: %@" , items.price);
        NSLog(@"Invalid product id: %@" , invalidProductId);
    }
    */

    //NSLog(@"Received products results..."); 
    NSLog(@"response product %@",response.products);
    self.products = response.products;
    self.request = nil;    

    [[NSNotificationCenter defaultCenter] postNotificationName:kProductsLoadedNotification object:_products];    
}

1 个答案:

答案 0 :(得分:1)

http://troybrant.net/blog/2010/01/in-app-purchases-a-full-walkthrough/

按照上面的教程.. 首先通过比较检查您的代码是否有效 ..如果是,那么.. 当您获得无效产品ID时,有一个特殊部分作为回报响应......通过它......