iOS in app purchase - no products received
Asked Answered
T

10

20

I'm trying to add in-app purchase to my app, following the techniques described here :

Introduction to In-App Purchases in iOS 6 Tutorial

I've added a product via itunes connect, which has an id set up like this:

com.mycompany.myapp.myproduct1

The bundle id (specified in the p-list and also on the app store) is set up like this:

 com.mycompany.myapp

I'm using the helper class from the tutorial, IAHelper, to handle the purchase functionality (relevant code shown below). It also has a subclass which is essentially used to add the id of the in-app product(s) to the IAHelper's array of products ids.

In order to test the code, I created a button labeled "show products" which calls this method:

- (IBAction) showProducts {

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(productsLoaded:) name:kProductsLoadedNotification object:nil];

    Reachability *reach = [Reachability reachabilityForInternetConnection]; 
    NetworkStatus netStatus = [reach currentReachabilityStatus];    
    if (netStatus == NotReachable) {        
        NSLog(@"No internet connection!");        
    } else {        
        if ([InAppMyAppAPHelper sharedHelper].products == nil) {


            // here's where it calls the helper class method to request the products
            [[InAppMyAppAPHelper sharedHelper] requestProducts];

            self.hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
            _hud.labelText = @"Loading vocabulary...";
            [self performSelector:@selector(timeout:) withObject:nil afterDelay:30.0];

        }        
    }

}

This is the method to request products from iTunesConnect, called above:

- (void)requestProducts {

    self.request = [[[SKProductsRequest alloc] initWithProductIdentifiers:_productIdentifiers] autorelease];
    _request.delegate = self;
    [_request start];

}

(Note that the variables preceded by "_" refer to the actual variables of the same name sans the underscore per several synthesize statements)

Finally, this is the method (in IAHelper) that gets notified when the response is received:

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {

    NSLog(@"IAHelper, received products results...");   

    self.products = response.products;
    self.request = nil;    

    // Here's the loop to list the products received
    for (id product in _products){
        NSLog(@"IAHelper, received product is: %@", product); 
    }


    [[NSNotificationCenter defaultCenter] postNotificationName:kProductsLoadedNotification object:_products];    
}

In the above, the log statements show the method is called, but the loop to print the received products doesn't list anything.

So it looks as if it's not finding the product in iTunes connect. Yet, I've set up a product there, and the id of the product is the same as the bundle id, plus the product identifier, i.e.

bundle id:  com.mycompany.myapp
product id: com.mycompany.myapp.product1

I've checked that several times.

I noticed that iTunes lists the status of the ad-in product as "ready to submit". Is there an additional step I need to make to make it available?

Overall, what am I doing wrong?

Tracheid answered 30/10, 2011 at 21:4 Comment(1)
I had same issue, In my case both catch and then section were executing, dont know why. I was testing in simulator. Testing in real devices works as intendedMariellemariellen
S
51

I run into the exact similar problem. Here are some steps that needs to be adressed/checked after reading this technical note from Apple:

  • Create a unique App ID
  • Enable in-app purchasing for this App ID
  • Generate and install a new provisioning profile on your device
  • Update the bundle ID and code signing profile in Xcode
  • Check that your project’s .plist Bundle ID match your App ID
  • Complete your contract, tax, and banking Information. You need a VALID contract

As mentioned by the official doc there is NO need to submit binaries neither submit screenshot of in-app purchase. I have seen a lot of missleading info about this on various blogs.

After checking you have addressed each point in this list, delete your app and reinstall it.

I was basically missing two things on my side: setting up correctly my contract for ios Paid app and i didn't install the new provisioning profile on my device. May be that was your issue?

Sordello answered 29/7, 2012 at 8:3 Comment(8)
Valid contract. That was my problem... :(Uncoil
made all from this list, and much more from other discussions. I thought it was my provision profile, but after fight with certificate hell, have same result...Frederickafredericks
I'm trying for sandbox testing at the moment, is this mandatory for contract, tax, and banking Information Valid. my current status pending...Biegel
Hope they fire the stupid ass that thought "valid contracts before testing IAP".Socialistic
@JPIllanes It's been 6 years, but do you happen to know how to determine if your contract is "valid"? On the "Agreements" page, my status for "Paid Apps" is "Active". Does that mean the contract is considered "valid"?Quadrennium
@Quadrennium No idea sorry, I don't even remember on what App I was working on at that time :(Uncoil
@JPIllanes No worries. For whatever it's worth to anyone reading this, I actually fixed my problem yesterday (which ended up being unrelated to the agreement/contract), so it's at least somewhat likely that "Active" indicates a "valid contract".Quadrennium
appstoreconnect.apple.com/agreementsRancor
L
2

Getting no valid products returned in productsRequest:didReceiveResponse is a well known issue. There are many reasons, some given in TN2259 especially FAQ#6. Usually the problem is that the app is not directing itself towards the sandbox. Often that is because the developer did not do these 3 things in order: 1) delete old builds of the app (delete, not overwrite) 2) log out of the app store on the device using the settings app 3) run the app from Xcode on a device (not a simulator) and log into the store using a test user only when asked by the app store.

Leroylerwick answered 30/9, 2014 at 4:21 Comment(0)
T
1

I have same problem while i m testing application on simulator.Try it in Device and its work for me.

Thruster answered 13/11, 2013 at 5:35 Comment(0)
S
1

I had the same issue. I filled the agreement for in app purchase, complete your contract, tax, and banking information so you have a valid contract. Also I added screenshots to the sections (App Store Promotion (Optional) and Review Information even though its says optional) in App Store Connect (in app purchases). Make sure your products in In-App Purchases have status Ready to Submit. Finally after that I got products.

Sphacelus answered 14/5, 2020 at 13:34 Comment(0)
K
0

I had a similar problem. I used code that was working in another app for IAPs so it should have been working, but I was getting an Invalid Product ID error and no results received. It turned out that it was a timing issue. I was trying to process the returned products before they'd been returned to the app, so the error was terminating the app before the products had time to be loaded! My program logic was:

  • User opens store view & IAP products are loaded
  • A UITableView is loaded with a list of the products (but from a locally held array)
  • The user clicks the buy button on a table cell - if this happens too quickly, the actual products haven't been returned yet - app crashes

Answer for me was to build the table from the returned products (should have been obvious to me in the first place!) so the user couldn't continue until they had been loaded correctly

Kalil answered 24/9, 2014 at 22:1 Comment(0)
F
0

Answer for Swift projects with same error:

My error was here:

//identifiers: [String]
let productIDs = Set(arrayLiteral: identifiers) as Set<NSObject>!
let request = SKProductsRequest(productIdentifiers: productIDs)

But this code will lead to an error with code = 0 message Cannot connect to iTunes Store. Let's look to the SKProductsRequest input argument type:

SKProductsRequest(productIdentifiers: Set<NSObject>!)

So, code above looks legit. But it doesn't! Swift Set is the problem, considering that in input argument we see Swift Set!

Found the answer while iterating some IAP lesson. Here is the working code:

let productIDs = NSSet(array: identifiers)
let request = SKProductsRequest(productIdentifiers: productIDs as! Set<NSObject>)

You must use NSSet for now, although Swift Set is already available and it's set as input argument type! Looks like a bug for me, I'll fire a bug.

Frederickafredericks answered 6/9, 2015 at 10:55 Comment(0)
I
0

We were stuck a while with the same problem trying to run it on the simulator.

After try it on a real Apple TV device (connected via USB) we started getting valid product IDs.

Then you only have to request the payment of one of these products on your code and you should be able to be requested to authenticate (with a sandbox user) and approve your purchase on the Apple TV.

Integral answered 9/9, 2016 at 18:7 Comment(0)
K
0

If you're following Apple's documentation you may end up in the same boat as me. If you're setting up for sandbox testing you need to make sure that the .storekit file is not set. Apple's documentation is a bit involved with this and it does ask you to do this under the section "Enable StoreKit Testing in Xcode"

Follow these instructions but make sure that StoreKit Configuration is set to None

Source: https://developer.apple.com/documentation/xcode/setting_up_storekit_testing_in_xcode#3625696

Karyotype answered 8/3, 2021 at 12:35 Comment(0)
T
-1

I think I may have found the answer here.

This wording from the in-app purchase web page led me to it:

The first In-App Purchase for an app must be submitted for review at the same time that you submit an app version. You must do this on the Version Details page. Once your binary has been uploaded and your first In-App Purchase has been submitted for review, additional In-App Purchases can be submitted using the table below.

What you can do to get around the catch-22 of not wanting to submit an app for review when you haven't tested the in-app purchase code is to submit it for review, and then immediately reject it on your own. This gives it a status of "developer rejected".

Then you can add your product, According to the blog,

After saving the product, just choose the “Submit with app binary” option. This will tie the product to the app binary, so when you finally submit the 100% complete app binary, the product will be submitted as well.

Tracheid answered 31/10, 2011 at 0:51 Comment(2)
This statement from the blog you are mentioning is outdated or incorrect. As per mentioned by the official doc: developer.apple.com/library/ios/#technotes/tn2259/_index.html: Testing In-App Purchase does not require uploading a binary.Sordello
The technote even says that you SHOULD NOT UPLOAD a binary. If it is rejected, or developer rejected, you need to have an app approved before you can test again!!Richy
T
-1

I had the same problem. The issue was a wrong BundleID

Trumpetweed answered 1/2, 2024 at 18:56 Comment(3)
Wrong where? What steps were taken to fix the issue? Please update your answer with far more details so it is more useful to future readers.Douce
Wrong means not correct. When change to a correct one, it fixed the issue Not sure what was so hard to understand.Trumpetweed
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Allembracing

© 2022 - 2025 — McMap. All rights reserved.