如何在iTunes Connect中测试我的应用内购买

3
我正在iOS SDK中的应用内购买中工作,并完成了所有步骤,比如在iTunes中创建应用程序,在iTunes Connect的管理应用内购买中创建了一个非消耗性应用程序。我的应用状态如下图所示: 等待上传

enter image description here

我的应用内购买状态是准备提交

enter image description here

代码上已经完成了应用内购买功能,但是当我测试我的应用时,SKProductsRequest 没有返回任何产品...!
我的主要应用程序包ID为com.mycompany.myapp
而我的应用内应用程序包ID为com.mycompany.paidapp
他们如何测试应用内购买步骤,能否有人指导我!以下是我的示例代码:
- (void)loadStore {

    if ([SKPaymentQueue canMakePayments]) {
        NSLog(@"Parental-controls are disabled");

        request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"com.mycompany.paidapp"]];
        //request.delegate = self;
        [request setDelegate:self];
        [request start];


    }
    else {
        NSLog(@"Parental-controls are enabled");
    }

}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {

    SKProduct *validProduct = nil;
    int count = [response.products count];
    if (count > 0) 
    {
        validProduct = [response.products objectAtIndex:0];
        NSLog(@"Products found!");
        [[NSNotificationCenter defaultCenter] postNotificationName:kProductsLoadedNotification object:@"Product Found..!"];

    } else if (!validProduct) 
    {
        NSLog(@"No products available");
        [[NSNotificationCenter defaultCenter] postNotificationName:kProductsLoadedNotification object:@"Product Not Found..!"];

    }

}

命令提示符总是返回以下输出的nslog:

没有可用的产品


您的应用内购买商店中是否存在 com.mycompany.paidapp 产品? - Mitesh Khatri
@Mitesh Khatri 在应用商店中不存在...! - Dinesh
然后将其添加到您的iTunes应用内购买中,然后再试一次。 - Mitesh Khatri
@ Mitesh Khatri 如果我要测试应用内购买,必须要上传二进制文件到App Store吗? - Dinesh
不需要在应用商店上传二进制文件。 - Mitesh Khatri
让我们在聊天中继续这个讨论:http://chat.stackoverflow.com/rooms/12544/discussion-between-mitesh-khatri-and-hero-vs-zero - Mitesh Khatri
2个回答

2

为了测试应用内购买,您可以创建一个AppID以及一些应用内购买内容,在发布应用之前,您应该好好检查它。

出于这个原因,我遵循的策略如下: 1. 首先上传一个应用程序。 2. 添加应用内购买内容。 3. 自己拒绝二进制文件。 当您对您的应用内购买测试满意后,重新加载新的二进制文件到iTunes中。

希望这有所帮助。


1

应用程序包名称和iTunes应用程序包名称应相同。并且产品必须存在于iTunes上。 请尝试以下代码:

[productIdentifierList addObject:@"CB001"];
[productIdentifierList addObject:@"CB002"];
[productIdentifierList addObject:@"CB003"];

        SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:productIdentifierList]];
        request.delegate = self;
        [request start];

CB001,CB002 是您在iTunes上的产品ID。

对我来说它很好用。


我的应用内购买标识符是com.mycompany.inapp,我该如何将其赋值给[productIdentifierList addObject:@"com.mycompany.inapp"]? - Dinesh

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接