Possible Duplicate:
what is the alternative solution for paymentWithProductIdentifier?
Hello I am trying to set up in app purchases for ios 5 and newly ios 6. I am being told that my "paymentWithProductIdentifier is deprecated" and I was wondering if someone could tell me how to modify my code, I am a little confused.
SKProduct *selectedProduct = <#from the products response list#>;
SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];
I have seen people suggest the following but I am not sure from my code what "the products response list would be". I thought it would be but its not.
[response.products];
Here is my code for the method, if anyone can tell me what to change it would be appreciated thanks!
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
SKProduct *validProduct = nil;
int count = [response.products count];
NSLog (@"count for in app purchases is %d", count);
if (count>0) {
validProduct = [response.products objectAtIndex:0];
SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"appUpdate1"];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment]; // <-- KA CHING!
NSLog (@"payment proccessed I think");
}
}
It looks like you're assuming that there is only one product, which you set to validProduct. You should be able to use
SKPayment *payment = [SKPayment paymentWithProduct:validProduct]
The productIdentifier is a property of the SKProduct, so this method creates the new payment object with the identifier it gets from the SKProduct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With