2

我正在尝试找出适用于 iOS 的应用内购买。由于 praymentWithProductIdentifer: 方法已被弃用,我一直被卡住。如果该方法仍然有效,这是我想使用的代码:

- (IBAction)pressBuy20CoinsButton: (id) sender
{

SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"com.mydomain.inappPractice.20Coins"];
[[SKPaymentQueue defaultQueue] addPayment:payment];

[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];

}

现在我到处看,它说更新的方法是 paymentWithProduct: 丢失了 Identifier 部分似乎很不方便。我假设编写我的方法的正确(更新)方式是这样的:

- (IBAction)pressBuy20CoinsButton: (id) sender
{

SKProduct *myProduct =  // not sure what to put here
SKPayment *payment = [SKPayment paymentWithProduct:myProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];

[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];

}

假设我只有 1 次应用内购买。我可以通过代码中的特定产品标识符以某种方式访问​​该产品吗?我定义 SKProduct *myProduct 的正确方法是什么?

4

1 回答 1

0

试试这个:如此处发布:StackOverflow 答案

SKProduct *selectedProduct = <#from the products response list#>;
SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];
于 2013-06-20T16:36:02.823 回答