Question

I'm trying to implement in app purchases in a free application.

I have created a productd id "test1" within the in app purchases manager in itunes connect portal.

When I make the product request in the following way:

- (id)init {

     NSSet *productIdentifiers = [NSSet setWithObjects:
                             @"test1",
                             nil];

     if ((self = [self initWithProductIdentifiers:productIdentifiers])) {                

}

return self;

}

- (id)initWithProductIdentifiers:(NSSet *)productIdentifiers
{    
if ((self = [super init]))
{
    // Store product identifiers
    _productIdentifiers = [productIdentifiers retain];

    // Check for previously purchased products
    NSMutableSet * purchasedProducts = [NSMutableSet set];

    for (NSString * productIdentifier in _productIdentifiers)
    {
        BOOL productPurchased = [[NSUserDefaults standardUserDefaults] boolForKey:productIdentifier];

        if (productPurchased)
        {
            [purchasedProducts addObject:productIdentifier];
            NSLog(@"Previously purchased: %@", productIdentifier);
        }

        NSLog(@"Not purchased: %@", productIdentifier);
    }

    self.purchasedProducts = purchasedProducts;
}

return self;

}

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

NSLog(@"Received products results...");   
self.products = response.products;
self.request = nil;    

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

NSLog(@"%d",[self.products count]);
NSEnumerator *e = [self.products objectEnumerator];

id object;

while(object=[e nextObject])
{
    NSLog(@"item");
    NSLog(@"%s",(char*)object);
}

}

- (void)requestProducts {

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

}

The response is always 0. I don't understand what am I doing wrong. This code came from a tutorial. The documentation regarding in app purchases tend to be quite confusing and the whole process in itunes connect doesnt give me confidence.

I thought the application needed to be online for sale for in app purchases to be working. However, I decided not to included in app purchases, but let the in app purchase in itunes connect for review. During the review process, the application was rejected because it should be working with the in app purchases for testing.

But how do I test in app purchases if the product listing comes always at zero?

If someone with more experience could give me an advice on this, since i'm already getting crazy with it!

Thanks,

With my best regards,

Nuno

Was it helpful?

Solution

The most coherent solution I found to this problem was this checklist. It should be wide spreaded in order to avoid anyone passing by the same problem which is really time consuming and desperating:

  • Have you enabled In-App Purchases for your App ID?
  • Have you checked Cleared for Sale for your product?
  • Have you submitted (and optionally rejected) your application binary?
  • Does your project’s .plist Bundle ID match your App ID?
  • Have you generated and installed a new provisioning profile for the new App ID?
  • Have you configured your project to code sign using this new provisioning profile?
  • Are you building for iPhone OS 3.0 or above?
  • Are you using the full product ID when when making an SKProductRequest?
  • Have you waited several hours since adding your product to iTunes Connect?
  • Are your bank details active on iTunes Connect? (via Mark)
  • Have you tried deleting the app from your device and reinstalling? (via Hector, S3B, Alex O, Joe, and Alberto)
  • Is your device jailbroken? If so, you need to revert the jailbreak for IAP to work. (via oh my god, Roman, and xfze)
  • Are you logged out from real iTunes account?
  • Have you tried restarting device?
  • Are you on Device? (Will not work on Simulator)

Credits go to Troy Brant

OTHER TIPS

Have a look here, that answered all of my questions (and the framework is simple to use, too :-):

http://blog.mugunthkumar.com/coding/iphone-tutorial-%E2%80%93-in-app-purchases/

But I have to say the whole in-app purchase thing is a PITA - my app just got released, and of course I downloaded it and checked the in-app purchase screen. Guess what, it came up completely empty!

After some reading up it seems that even if all is accepted and ready for sale, the in-app purchase products still need a while to become available online - after 3 hours it finally worked ...

EDIT:

You need to create the in-app purchase for your app and set it to clear for sale in itunes connect. You do not need to upload a screenshot yet or have it already reviewed in order to be able to test it in development mode.

How did you name the purchase in itunes connect? Normally you should use a com.companyname.productname.purchasename name, and the name you request from your app ha to be exactly the same.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top