0

I have a free iPhone App which uses in app purchase. I tested my first InAppPurchase with sandbox environment and it worked fine. After the InAppPurchase was approved and worked fine in App store, I added several new InAppPurchases in iTunes Connect and tried to test them in the sandbox environment. However I could not find these new InAppPurchases in my app.

The following is the code I uses to get InAppPurchase products:


//....

SKProductsRequest *prodRequest= [[SKProductsRequest alloc] initWithProductIdentifiers:
                [NSSet setWithObject: prod]];
prodRequest.delegate = self;
[prodRequest start];

//....

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
    int count = [response.products count];

    NSLog(@"number of products:%d",count);
    for (int i=0; i < count; i++) {
        SKProduct* product = [response.products objectAtIndex:i];
        NSLog(@"product %d:id=%@ title=%@ desc=%@ price=%@", i, product.productIdentifier, product.localizedTitle, 
             product.localizedDescription,
             product.price);
    }
}


If I use the old InAppPurchase product id I can get it, but if I use any newly created product id I got count==0.

From what I saw, I guess may app may not be running in the sandbox environment after my first InAppPurchase was approved, but this is just a guess, because I don't know how to check if my app is in sandbox mode or not.

I searched Internet about this issue and tried the following: 1. created a new version of my app, uploaded it to iTunes connect, and rejected the binary. no use 2. deleted all my provisioning profiles and created new ones. no use 3. created an app id for my app in developer provisioning portal and created provisioning profile for that id and used it in Xcode. no use

My Xcode version was 3.2.5. I upgraded it to 4 but this did not fix the problem.

I am wondering if any one else has seen this issue and found a solution. Thanks.

4

1 回答 1

2

好的,我遇到了这篇文章并得到了一些提示:

产品标识符在一部手机上有效,但在另一部手机上无效

我刚刚从我的 iPod Touch 中删除了该应用程序,没有重新启动,然后尝试再次从 Xcode 运行我的应用程序,它工作正常。我想有一些状态与应用程序一起保存,它决定是否为 InAppPurchase 使用沙盒环境。虽然我可以在不删除旧应用程序的情况下运行我新编译的二进制文件,但我无法摆脱一些导致应用程序无法在沙盒环境中运行的旧状态。这就是导致问题的原因。解决方案是在运行新编译的二进制文件之前从设备中删除旧应用程序。

于 2011-04-03T22:01:24.623 回答