Reputation: 136
I am trying to test in app purchase for non-consumable. It works fine. I have 10 products. I want to select several products and buy in one transaction. I tried array with SKPayment method. It doesn't work. How do I buy multiple product one click?
Single product work fine;
func paymentQueueWithProduct(product : SKProduct){
SKPaymentQueue.defaultQueue().addTransactionObserver(self);
let payment = SKPayment(product: product);
SKPaymentQueue.defaultQueue().addPayment(payment);
}
I need to buy several product one transaction. For example;
func paymentQueueWithProduct(products : [SKProduct]){
SKPaymentQueue.defaultQueue().addTransactionObserver(self);
let payment = SKPayment(product: products);
SKPaymentQueue.defaultQueue().addPayment(payment);
}
Upvotes: 3
Views: 3857
Reputation: 18922
You cannot purchase multiple products in a single transaction unless they are multiple of the same product (you can set a quantity of up to 10).
Perhaps consider adding IAPs that combine the benefits of groups of your existing IAPs (for example if you sell "level 1" "level 2" "level 3" consider selling "level 1-3" as well.
Unrelated, but you might want to observe the payment queue only once, rather than trying to add yourself as an observer each time a purchase is attempted.
Payment is described here and only discussed buying one product at a time:
Upvotes: 3