In-App Purchases: Stuck at paymentWithProductIdent

2019-03-30 20:16发布

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.

1条回答
聊天终结者
2楼-- · 2019-03-30 21:08

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

查看更多
登录 后发表回答