Reputation: 711
I integrated the In-App purchase for my app. I also set the purchase on itunes & shows me status as Ready to Submit
.
But I want to test it without submitting the binary.
So, Is there is another set required for Sandbox In-App testing?
My code:
[[SubclassInAppHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
if (success)
{
[appDel dismissGlobalHUD];
NSMutableArray *arrProductsBuyHeart = [[NSMutableArray alloc]init];
NSMutableArray *arrTemp = [[NSMutableArray alloc]init];
for (SKProduct *Sss in products)
{
NSString *string = Sss.productIdentifier;//@"hello bla bla";
if ([string rangeOfString:@"com.xxxxxxxx.buy"].location == NSNotFound) {
//NSLog(@"string does not contain Buy");
} else {
NSMutableDictionary *dictprod = [NSMutableDictionary dictionary];
[dictprod setObject:Sss.productIdentifier forKey:@"ProductIdentifier"];
[dictprod setObject:Sss.price forKey:@"ProductPrice"];
[dictprod setObject:Sss.localizedTitle forKey:@"ProductTitle"];
[arrTemp addObject:dictprod];
}
}
if (arrTemp.count > 0)
{
NSSortDescriptor *brandDescriptor = [[NSSortDescriptor alloc] initWithKey:@"ProductPrice" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObject:brandDescriptor];
arrProductsBuyHeart = [NSMutableArray arrayWithArray:[arrTemp sortedArrayUsingDescriptors:sortDescriptors]];
//NSLog(@"My products > %@",arrProductsBuyHeart);
for (int i = 0;i<[arrProductsBuyHeart count];i++)
{
NSString *strProductID = [[NSString stringWithFormat:@"%@",[[arrProductsBuyHeart objectAtIndex:i] objectForKey:@"ProductIdentifier"]]RemoveNull];
NSString *strPrice = [[NSString stringWithFormat:@"$%@",[[arrProductsBuyHeart objectAtIndex:i] objectForKey:@"ProductPrice"]]RemoveNull];
if ([strProductID isEqualToString:InApp200Coins])
{
[btn1KHeart setTitle:[NSString stringWithFormat:@"%@",strPrice] forState:UIControlStateNormal];
}
else if ([strProductID isEqualToString:InApp600Coins])
{
[btn2KHeart setTitle:[NSString stringWithFormat:@"%@",strPrice] forState:UIControlStateNormal];
}
else if ([strProductID isEqualToString:InApp900Coins])
{
[btn4KHeart setTitle:[NSString stringWithFormat:@"%@",strPrice] forState:UIControlStateNormal];
}
else if ([strProductID isEqualToString:InApp2KCoins])
{
[btn10KHeart setTitle:[NSString stringWithFormat:@"%@",strPrice] forState:UIControlStateNormal];
}
else if ([strProductID isEqualToString:InApp4KCoins])
{
[btn50KHeart setTitle:[NSString stringWithFormat:@"%@",strPrice] forState:UIControlStateNormal];
}
}
}
else
DisplayAlertWithTitle(@"Error Message", @"Unable to get product list or no in-app purchase found.");
}
else
{
[appDel dismissGlobalHUD];
DisplayAlertWithTitle(@"Error Message", @"Unable to get product list or no in-app purchase found.");
}
}];
}
Output DisplayAlertWithTitle(@"Error Message", @"Unable to get product list or no in-app purchase found."); & Not able to get Product List.
Help me to solve this.
Upvotes: 2
Views: 4975
Reputation: 1764
Create a test user account in iTunes Connect, as described in “Creating Test User Accounts” in iTunes Connect Developer Guide.
On a development iOS device, sign out of the App Store in Settings. Then build and run your app from Xcode.
On a development OS X device, sign out of the Mac App Store. Then build your app in Xcode and launch it from the Finder.
Use your app to make an in-app purchase. When prompted to sign in to the App Store, use your test account. Note that the text “[Environment: Sandbox]” appears as part of the prompt, indicating that you’re connected to the test environment.
If the text “[Environment: Sandbox]” doesn’t appear, you’re using the production environment. Make sure you’re running a development-signed build of your app. Production-signed builds use the production environment.
Important: Don’t use your test user account to sign in to the production environment. If you do, the test user account becomes invalid and can no longer be used.
Upvotes: 0
Reputation: 969
First of you can create app in itunes connect.
-add product in In-app purchase.
-then after itunes home page you can add test user click on manage user.
after add you can remove your apple account in your device then login with test user
after login you can test in-App purchase in Sandbox mode.
Upvotes: 3