Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In-App Purchases: Stuck at paymentWithProductIdentifiers - which is deprecated

I am stuck with setting up my in-app purchases.

I can't get to get this right:

SKPayment *paymentRequest = [SKPayment paymentWithProduct: @"co.za.nideo.100shotsbuybeer"];

I got it from

SKPayment *paymentRequest = [SKPayment paymentWithProductIdentifiers: @"co.za.nideo.100shotsbuybeer"];

but this seems to be deprecated. How can I get the first piece of code to work?

It seems to nee a SKProduct but I don't know how to create/init such an object.

like image 780
Pangolin Avatar asked Dec 28 '22 10:12

Pangolin


1 Answers

According to the StoreKit docs and [1] you'd have to:

  1. Create an SKProductsRequest with your product identifiers (initWithProductIdentifiers:)
  2. Set yourself as the delegate
  3. Send this request to Apple (start method)
  4. The Response will call your delegates productsRequest:didReceiveResponse: which contains an SKProductsResponse object
  5. You extract the SKProduct objects from the products property and display them, saving the objects for further purchase.

This seems in line with Important: You must make a product request for a particular product identifier before allowing the user to purchase that product. Retrieving product information from the App Store ensures that you are using a valid product identifier for a product you have marked available for sale in iTunes Connect. from [1]

[1] http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/RetrievingStoreInformation/RetrievingStoreInformation.html#//apple_ref/doc/uid/TP40008267-CH2-SW1

like image 172
Dennis Bliefernicht Avatar answered Feb 03 '23 14:02

Dennis Bliefernicht