HarshIT
HarshIT

Reputation: 4915

In App Purchase Products not found

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.

Upvotes: 9

Views: 8867

Answers (4)

rasulfahad
rasulfahad

Reputation: 624

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.

Upvotes: 1

Rekha.t
Rekha.t

Reputation: 161

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.

Upvotes: 4

Akash Thakkar
Akash Thakkar

Reputation: 941

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

Upvotes: 18

Ali
Ali

Reputation: 19722

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.

Upvotes: 1

Related Questions