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?