【发布时间】:2026-01-11 11:55:01
【问题描述】:
我为我的应用集成了应用内购买。我还在 iTunes 上设置了购买并将状态显示为Ready to Submit。
但我想在不提交二进制文件的情况下对其进行测试。
那么,沙盒应用内测试还需要另外一套吗?
我的代码:
[[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.");
}
}];
}
输出 DisplayAlertWithTitle(@"错误信息", @"无法获取产品列表或未找到应用内购买。"); & 无法获取产品列表。
帮我解决这个问题。
【问题讨论】:
标签: ios xcode in-app-purchase sandbox