【问题标题】:Consumable InApp purchase for a single product?单个产品的 Consumable In App 购买?
【发布时间】:2013-04-14 11:41:26
【问题描述】:
【问题讨论】:
标签:
ios
xcode
in-app-purchase
【解决方案1】:
您需要传递 skproduct 而不是其标识符,这并没有太大区别,您只需事先请求产品,以便在付款时可以使用它。
//This is how you request the products with a list of identifiers
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:self.productIdentifiers];
[request setDelegate:self];
[request start];
//This is the delegate method called after there is a response from apple servers
-(void) productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
self.products = response.products;
for (SKProduct *product in self.products)
{
if ([product.productIdentifier isEqualToString:MY_PRODUCT_IDENTIFIER])
{
self.myProduct = product;
}
}
}
//And this is how you do the actual payment after product is retrieved
SKPayment * payment = [SKPayment paymentWithProduct:self.myProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];
据我所知,事务部分的工作方式与教程中的相同,因为我经历了相同的教程。