Scrungepipes
Scrungepipes

Reputation: 37600

Reasons for SKProductsRequest returning 0 products?

I'm trying to set up IAP but after making a call to retrieve the products using SKProductsRequest the SKProductsResponse array within my delegate has a count of 0. Here's my checklist:

Any other suggestions as to why the fetched product count is zero?

I don't believe this will be a coding issue, but here it is anyway:

…

NSSet *productIdentifiers = [NSSet setWithObjects:@"redacted", nil];
self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
self.productsRequest.delegate = self;
[self.productsRequest start];

…
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    NSArray *products = response.products;
    NSLog(@"Product count: %d", [products count]);
    for (SKProduct *product in products)
    {
        NSLog(@"Product: %@ %@ %f", product.productIdentifier, product.localizedTitle, product.price.floatValue);
    }
}

Upvotes: 61

Views: 29158

Answers (16)

Renars
Renars

Reputation: 83

Below is a troubleshooting checklist for the case when SKProductsRequest returns zero products (source https://fluffy.es/zero-iap-products-checklist):

  1. You must have a paid Apple developer account
  2. Your free and paid apps agreements status are active
  3. You have added the necessary Tax information
  4. You have added Banking information
  5. You have created an explicit App ID for your app
  6. You have created an app in App Store Connect, with the correct App ID
  7. You have created the in-app purchase item in App Store Connect
  8. Your in-app purchase product status is 'Ready to Submit'
  9. Your app is using the correct signing Team / provisioning profile
  10. Your app's bundle ID in Xcode is the same as App Store Connect
  11. You have added In-App Purchase capability to your app's Xcode project
  12. You are using the correct product ID when calling SKProductsRequest
  13. You have waited at least 15 minutes after creating In-App Purchase item Subscription to access all app content and content updates.

Upvotes: 5

CoderChick
CoderChick

Reputation: 232

Swift 5 xcode 12.4 simulator returned zero products.

Using a physical device returned products properly

Upvotes: 1

BharathRao
BharathRao

Reputation: 2056

I had this issue even after accepting the Tax and Agreements Section in App Store. I use to change my Apps bundle Id many times(for sending builds to testers), I suspected this could be the issue. So I fixed this issue as follows.
Go to Target -> BuildSettings -> Search for "Product Bundle Identifier". It should be $(PRODUCT_BUNDLE_IDENTIFIER).
After updating this go to General -> Bundle Identifier. Enter your proper bundle Id which has In-App purchase capability. After doing this changes I'm able to list the products

Upvotes: 0

Talha Rasool
Talha Rasool

Reputation: 1152

IN swift 5, I am facing the same problem getting Skproducts count 0. I solved this Goto enter image description hereiTunes Connect -> Agreements and Tax if status is New there then there should be term view button besides status click it fill the complete form and then the paid apps will be shown status active and Skproducts counts would be visible in xcode console.

Upvotes: 5

iamVishal16
iamVishal16

Reputation: 1780

I had the same issue...

I simply change my bundle identifier which does not match with an iTunes bundle identifier.

And my app runs well :)

Upvotes: 16

Nike Kov
Nike Kov

Reputation: 13761

In my case that was a bug. In simulator all product identifiers fails and was marked as invalid. In real device all product request successfully fetched a product.

TvOS 4K

Upvotes: 0

ATV
ATV

Reputation: 4536

I'm getting an empty SKProductsResponse.products array on some macOS 10.14 systems while others work just fine and return the valid list of current IAPs for my app.

Same app, identical code.
User logged into the same App Store account on both machines.

That's just plain weird.

Upvotes: 1

Tai Le
Tai Le

Reputation: 9296

Let's go to iOS's Settings > iTunes & App Stores and Log out

Hope this help you, I don't know why :D

Upvotes: 1

Maverick
Maverick

Reputation: 3269

After digging a lot, following steps solved my issue of getting 0 products for SKProductsRequest.

Go to Settings > Sign in to your iPhone on your iOS device. If you're already logged in with your original Apple ID, tap on it and choose Sign Out. Then simply sign in with the credentials for the sandbox tester you created in iTunes Connect.

Upvotes: 0

Matjan
Matjan

Reputation: 3607

Also, keep in mind that agreeing to the Paid Applications cotract is not enough. You also have to fill out the contact, bank and tax information for that agreemant specifically, for it to be considered done.

Upvotes: 2

Desert Rose
Desert Rose

Reputation: 3434

Please also whether you have set price of the product in iTunesConnect or not.I missed that and products were zero.Wasted my whole day to figure out this.

Upvotes: 1

Ivan Besarab
Ivan Besarab

Reputation: 1008

Check all 3 things in the list below
1) check your product identifiers - they must be exactly the same that you have in your code and in iTunes Connect -> My Apps -> YourAppName -> Features -> In-App Purchases enter image description here 2) iTunes Connect -> Agreements, Tax, and Banking -> Master Agreements -> Paid Applications-> Contact Info / Bank Info / Tax Info (should be filled)enter image description here 3) code to test it

class ViewController: UIViewController {

    var requestProd = SKProductsRequest()
    var products = [SKProduct]()

    override func viewDidLoad() {
        super.viewDidLoad()

        validateProductIdentifiers()
    }
}

extension ViewController: SKProductsRequestDelegate {

    func validateProductIdentifiers() {
        let productsRequest = SKProductsRequest(productIdentifiers: Set(["candy100", "someOtherProductId"]))

        // Keep a strong reference to the request.
        self.requestProd = productsRequest;
        productsRequest.delegate = self
        productsRequest.start()
    }

    // SKProductsRequestDelegate protocol method
    public func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {

        self.products = response.products

        for invalidIdentifier in response.invalidProductIdentifiers {
            print(invalidIdentifier)
        }

    }
}

Upvotes: 47

nspire
nspire

Reputation: 1731

In the off chance that you've overlooked this, the product identifier match is case sensitive.

So, if you've created a product on Apple with an identifier of say

com.yourcompany.product1

and you call the product request with a product identifier of

com.yourcompany.Product1

Your list will be returned with zero products.

This kept me busy for a while :-)

ps: On a separate project, I found SKProductsRequest only started returning products after a restart. So, if all else fails, try restarting your Mac.

Upvotes: 8

Elijah
Elijah

Reputation: 8610

Make sure you have In-App Purchase turned on in the Capabilities section. If you don't, SKProductsRequest will return 0 products.

Upvotes: 20

Ahsan Ebrahim Khatri
Ahsan Ebrahim Khatri

Reputation: 1847

I was facing the same problem, Solved it by sending just the IAP Product name rather than my bundle id before the product name. Here is the example :

works SKProductsRequest *productRequest = [[SKProductsRequest alloc]initWithProductIdentifiers:[NSSet setWithObject:@"my_product"]];

rather than

doesn't work SKProductsRequest *productRequest = [[SKProductsRequest alloc]initWithProductIdentifiers:[NSSet setWithObject:@"com.my_site.my_app.my_product"]];

Upvotes: 14

virindh
virindh

Reputation: 3765

Some times there are very carrying solutions to these types of problems. After doing some research, I found that it sometimes helps to delete the app and then install it again(In-App Purchase, SKProductsRequest returning 0 - Products still in Review) Also what version of iOS are you using?

Upvotes: 2

Related Questions