9

I have created an app with bundle identifier

com.myapp

Now I added two In App Purchase items. Following are the product ids

com.myapp.product1

com.myapp.product2

Now when I fetch list of products, it does not show any product.

I use following code to load products list

  let request = SKProductsRequest(productIdentifiers: Set(remainingIds))
        request.delegate = self
        loadProductsRequests.append(LoadProductsRequestInfo(request: request, completion: completion))
        request.start()

The code works fine, If I use other project's product & bundle ids. But when I try for my project, it can't load list of products

It seems the issue is due to the structure of bundle identifier. Kindly help me.

Community
  • 1
  • 1
HarshIT
  • 4,583
  • 2
  • 30
  • 60

4 Answers4

18

Your code seems proper to request the products.

Make sure you have added your products with bundle ids and other required details under iTunes Connect application under in-app purchase category.

One more thing - Apple will not allow receiving the product list from in-app until you fill the forms under “Agreement tax and Banking” on iTunes connect.

Below is the code to receive the product list which may helpful to you.

func productsRequest (_ request: SKProductsRequest, didReceive response: SKProductsResponse) {

        let count : Int = response.products.count
        if (count>0) {
            var validProducts = response.products
            var validProduct: SKProduct = response.products[0] as SKProduct

            if (validProduct.productIdentifier == self.product_id) {
                print(validProduct.localizedTitle)
                print(validProduct.localizedDescription)
                print(validProduct.price)
                buyProduct(product: validProduct);

            } else {
                print(validProduct.productIdentifier)
            }
        } else {
            print("nothing")
        }
    }

Here product_id = "com.myapp.product1" or "com.myapp.product2".

Also, enable the In-App purchase from Capabilities:

In-App Purchase

shim
  • 9,289
  • 12
  • 69
  • 108
Akash Thakkar
  • 941
  • 1
  • 6
  • 16
  • This code doesn't work anymore... Sorry. EDIT: Apologies! It works, but not on real devices which is really weird. Any thoughts? (I've removed my downvote) – Linus Dec 12 '22 at 14:17
4

In case of In-app purchase you have to do the following:

Login into iTunes Connect

Click “Users and Roles” and add “sandbox tester” Details to test the app with dummy payment • Click on “Agreement tax and Banking” Check For contract Type ,add needed account info,Bank info and Tax info. • On the iTunes Connect homepage, click the “Manage Your Applications” link • In the top-right corner, click “Create New Application” • Fill out all the requested information for your app. When asked for your application binary, check the box indicating you will upload it later.

It may take a day for you to get your desired list of products.

CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
Rekha.t
  • 161
  • 6
  • 14
  • 1
    I have already gone through that procedure. That is not the issue. – HarshIT Mar 23 '17 at 17:16
  • The issue is I am not getting products list in my app. – HarshIT Mar 23 '17 at 17:16
  • I've had this exact problem, and it *was* due to the issue described in this answer (or a slight variation). I think the in-app purchase API is intentionally obtuse so it can't be manipulated. Though it seems odd from a developer's perspective, not having the "paperwork" correct for your account *does* cause the issue you're seeing. I know it's frustrating, but try going through everything in your account, your app setup, entitlements, etc. and see if there's a box you forgot to check or an agreement you didn't sign. The mysterious ways of Apple... – Anna Dickinson Apr 08 '17 at 20:10
1

As silly as it is, after I fixed all the problems mentioned in other response, I found out I had a slightly different Bundle ID in my app and on the Appstore connect.

So make sure your Bundle id matches between App Store connect and you app.

Ali
  • 18,665
  • 21
  • 103
  • 138
0

Happened with me. Hours of debugging until I was convinced there was nothing wrong with code, bundle identifiers, Xcode profiles and bundle Ids.

What was happening was, I had recently renewed my Apple Developer membership and had not updated the paid-app contract. Once I did that, things were back to normal and my in-app-products were returned after SKProductsRequest

You can check this answer on their forum: The contract must be signed by you and Apple. This can keep the SKProductsRequest from validating the identifiers.

rasulfahad
  • 443
  • 3
  • 13