Every I try to use In App Purchase, it says 'No Products Found' in the console. I double checked that the IBAction was hooked up to the button, and I got this code off of a tutorial. YouTube - XCode Tutorial: In-App Purchase
If anyone knows why this is happening or if there is something wrong in my code, let me know...
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
SKProduct *validProduct = nil;
int count = [response.products count];
if (count > 0) {
validProduct = [response.products objectAtIndex:0];
}
else if (!validProduct) {
NSLog(@"No products available");
}
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
NSLog(@"Purchasing Now");
break;
case SKPaymentTransactionStatePurchased:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
//Call showlabel method to show the label
[self showlabel];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:@"test" forKey:@"stringVal"];
[prefs synchronize];
UIImage *image = [UIImage imageNamed: @"P2-3-Main-P.png"];
[background setImage:image];
NSLog(@"Transaction Purchased");
break;
case SKPaymentTransactionStateRestored:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
NSLog(@"Transaction Restored");
break;
case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
NSLog(@"An error encountered");
}
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
}
}
}
- (void)showlabel {
[scorelabel setHidden:NO];
}
In the viewdidload:
Code:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// getting the string
iapstring = [prefs stringForKey:@"stringVal"];
//Free Version
if (iapstring == nil) {
//Action
UIImage *image = [UIImage imageNamed: @"P2-3-Main-L.png"];
[background setImage:image];
}
//Paid Version
if (iapstring != nil) {
//Action
UIImage *image = [UIImage imageNamed: @"P2-3-Main-P.png"];
[background setImage:image];
}
[scorelabel setHidden:YES];
if ([SKPaymentQueue canMakePayments]) {
NSLog(@"Parental-controls are disabled");
//Put the link to the IAP from iTC in the string otherwise IAP will not work
SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:kInAppPurchaseProUpgradeProductId]];
productsRequest.delegate = self;
[productsRequest start];
//Not sure if you need the below line, check if it works
//[productsRequest release];
} else {
NSLog(@"Parental-controls are enabled");
}
}
iapstring is a nsstring i used in the nsuserdefaults to check if the item was purchased.
Update 2-23-11: I used a define to make it so I only had to put the product id in once and then use the define in the bolded lines to make it easier on myself. If anyone sees anything wrong, just post.
Thanks
Last edited by Objective Zero; 02-23-2011 at 11:21 AM.
Reason: 2-23-11 Added new code (Bolded)
Right now, I waited about 30 hours after I updated iTC. I am still using the same code above but changed one thing. And you can the changes in bold above.
I changed the product id for the IAP to match the product id for the app but at the end I added a .platinum. Now I waited about 17 hours after I did so and still get 'No Products Available', and 'An Error Encountered'. Anyone have any ideas why?
I had the same issue. My products did not want to show up (in fact, they were in the list of invalid product identifiers in the response object). What helped is removing the app from the device and doing a new build. Then it magically worked again.
No, you just need to upload a screenshot of what the app will look like after the IAP is bought. Then you can test before it is submitted.
Thanks for reply...I have done that. But still not getting product details ..So i googled it and found that before setting up IAP i have to sign Paid Contracts under "Contracts, Bank and TAX"..
I have my bank info ready but what abt TAX??? I m from India. What info i required to make this "Contracts In Effect".
Signed contract
Correct productids
Current app in the store with full unique bundle id
Products in itunes connect are marked as cleared for sale and screenshot attached to items
Provision files have been completely redone (deleted locally and phone and rebuilt using the ones I just got from portal)
Delete app from phone
Ran from XCode
They show in the simulator but not the device when I run from xcode to the device.
I have everything working fine one device, but on another it doesnt load any of the products, how can this be? The only thing can be different are the provisional profiles yeah?
check these
1. Ur bundle id - com.mycompany.myappname
2. No need of uploading binary and screenshot
3. should not be a jailbroken phone
4. building for iPhone OS3.0 and above
5. u r not using wildcard rght?
Last edited by Achuaswani; 01-12-2012 at 03:27 AM.
check these
1. Ur bundle id - com.mycompany.myappname
2. No need of uploading binary and screenshot
3. should not be a jailbroken phone
4. building for iPhone OS3.0 and above
5. u r not using wildcard rght?
#3 got me good. I love my JB though.
Anyways, I restored my phone and ran my app on the device and it worked as I expected. In App products showing up now. Thanks!
And no, I dont use wildcards for any of my apps. Seems like a waste and limiting yourself.