I am trying to test In App Purchases on my iPhone and running into a problem where the product IDs I request information for end up being returned to me as invalid product IDs in the "didRecieveResponse" method.
I have:
Everything seems to be in place, however I still get my products returned to me as invalid IDs.
This is the code I am using:
- (void)requestProductData {
SKProductRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject: @"com.domain.appname.productid"]];
request.delegate = self;
[request start];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSArray *myProducts = response.products;
NSArray *myInvalidProducts = response.invalidProductIdentifiers;
for(int i = 1; i < myInvalidProducts.count; ++i)
{
std::cout <<"invalid product id = " << [[myInvalidProducts objectAtIndex:i] UTF8String] << std::endl;
}
for(int i = 0; i < myProducts.count; ++i)
{
SKProduct * myProduct = [myProducts objectAtIndex:i];
std::cout << "Product Info:" << std::endl;
std::cout << "\tlocalizedTitle = " << [[myProduct localizedTitle] UTF8String] << std::endl;
std::cout << "\tlocalizedDescription = " << [[myProduct localizedDescription] UTF8String] << std::endl;
std::cout << "\tproductIdentifier = " << [[myProduct productIdentifier] UTF8String] << std::endl;
std::cout << "\tprice = " << [[myProduct price] doubleValue] << std::endl;
std::cout << "\tpriceLocale = " << [myProduct priceLocale] << std::endl;
}
[request autorelease];
}
All my product IDs show up in the invalid printouts and none of them show up in the "Product Info:" printouts.
Any suggestions would be greatly appreciated...
P.S. Yes, this is built as Objective-c/c++.
I tried everything suggested in the Apple forums and here, and still couldn't get it to work. Found the solution - your app needs to be transferred by Xcode for the sandbox to be enabled.
Obvious, right? Well, if you are working with an update to an existing account, the device will still treat it as an App Store-installed app.
Delete it, then transfer it again. It should work now :)
Deleting the app on the testing iPhone and reinstalling it worked. Also I had also waited 8 hours since submitting the in-app purchase item.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With