Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在IOS中设置应用内购买沙盒_Ios_Xcode_In App Purchase_Sandbox - Fatal编程技术网

如何在IOS中设置应用内购买沙盒

如何在IOS中设置应用内购买沙盒,ios,xcode,in-app-purchase,sandbox,Ios,Xcode,In App Purchase,Sandbox,我为我的应用集成了应用内购买。我还在itunes上设置购买并将状态显示为“准备提交” 但是我想在不提交二进制文件的情况下测试它 那么,沙盒应用程序内测试是否还需要另一套 我的代码: [[SubclassInAppHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) { if (success) {

我为我的应用集成了应用内购买。我还在itunes上设置购买并将状态显示为“准备提交”

但是我想在不提交二进制文件的情况下测试它

那么,沙盒应用程序内测试是否还需要另一套

我的代码:

    [[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.");
        }
    }];
}
[[SubassinappHelper sharedInstance]requestProductsWithCompletionHandler:^(BOOL success,NSArray*产品){
如果(成功)
{
[appDel dismissGlobalHUD];
NSMutableArray*arrProductsBuyHeart=[[NSMutableArray alloc]init];
NSMutableArray*arrTemp=[[NSMutableArray alloc]init];
用于(SKProduct*Sss在产品中)
{
NSString*string=Sss.productIdentifier;/@“hello bla bla bla”;
if([string rangeOfString:@“com.xxxxxxxx.buy”].location==NSNotFound){
//NSLog(@“字符串不包含购买”);
}否则{
NSMutableDictionary*dictprod=[NSMutableDictionary];
[dictprod setObject:Sss.productIdentifier forKey:@“productIdentifier”];
[dictprod setObject:Sss.price forKey:@“ProductPrice”];
[dictprod setObject:Sss.localizedTitle forKey:@“ProductTitle”];
[arrTemp addObject:dictprod];
}
}
如果(ARRTTEMP.count>0)
{
NSSortDescriptor*brandDescriptor=[[NSSortDescriptor alloc]initWithKey:@“ProductPrice”升序:是];
NSArray*sortDescriptors=[NSArray阵列WithObject:brandDescriptor];
arrProductsBuyHeart=[NSMutableArray arrayWithArray:[arrTemp sortedArrayUsingDescriptors:sortDescriptors];
//NSLog(@“我的产品>%@”,arrProductsBuyHeart);

对于(int i=0;i,首先可以在itunes connect中创建应用程序

-在应用内购买中添加产品

-然后在itunes主页之后,您可以添加测试用户,单击管理用户

添加后,您可以删除设备中的apple帐户,然后使用测试用户登录


登录后,您可以在沙箱模式下测试应用内购买。

在iTunes Connect中创建测试用户帐户,如中的“创建测试用户帐户”所述

在开发iOS设备上,在“设置”中注销应用商店。然后从Xcode生成并运行应用

在开发OS X设备上,注销Mac应用商店。然后在Xcode中构建应用程序并从Finder启动

使用您的应用进行应用内购买。当提示您登录应用商店时,请使用您的测试帐户。请注意,文本“[Environment:Sandbox]”作为提示的一部分出现,表示您已连接到测试环境

如果文本“[Environment:Sandbox]”未出现,则表示您正在使用生产环境。请确保您正在运行应用程序的开发签名版本。生产签名版本使用生产环境。


重要提示:不要使用您的测试用户帐户登录到生产环境。如果使用,测试用户帐户将无效且无法再使用。

不,您可以在您的设备中进行测试。好的。非常感谢您的回答!过一段时间后让我检查,如果有任何问题,请给您回电话,否则接受作为回答。这将不会发生在ios6模拟器上运行rk。但响应会有点慢。这是网络问题。虽然您可以单击购买它,但可以从服务器获取产品详细信息。因此,这需要很少的时间。从iOS7开始,不可能在模拟器中的应用程序中进行测试(: