Hi i am using in APP purchase in my project . When i run this project everything works fine, except i am getting a warning message saying that "paymentWithProductIdentifier is deprecated", I gone through the similar questions that are asked in stack overflow but i didn't satisfied. I shown you my coding that i used in the project below
SKPayment *payment=[SKPayment paymentWithProductIdentifier:@"com.mycompany.dmaker.maker1"];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];
Can anyone tell me 1)the alternative for this warning. 2)or tell me whether this project approve in appstore if i use this existing code.
Try using this:
SKProduct *selectedProduct = <#from the products response list#>;
SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];
You can replace paymentWithProductIdentifier:
with following codes:
// SKPayment *payment = [SKPayment paymentWithProductIdentifier:productId];
// [[SKPaymentQueue defaultQueue] addPayment:payment];
NSSet *productIdentifiers = [NSSet setWithObject:productId];
self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
self.productsRequest.delegate = self; // your wrapper for IAP or AppDelegate or anything
[self.productsRequest start];
while productsRequest
is a retain property.
And implement a SKProductsRequestDelegate method:
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
for (SKProduct *product in response.products) {
SKPayment *payment = [SKPayment paymentWithProduct:product];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
self.productsRequest = nil;
}
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