2011-07-11 97 views
3

我知道它已经被问过:iPhone In App Purchase - response.products are still empty?应用程序内购买response.products空

但我也试图在应用程序内购买来实现的,我的response.products是空的。 我的情况:

我上传并拒绝了我的二进制文件一次。

但后来我把状态再次返回到等待上传。(有没有关系呢?)

我所有的在应用程序内购买产品的状态是“准备提交”。

我的生产用户已注销。测试用户尚未登录。

-(void) requestProductData{ 
    SKProductsRequest *productRequest= [[SKProductsRequest alloc] 
           initWithProductIdentifiers:[NSSet setWithObjects: 
                  @"com.mydomain.myapp.Pack1", 
                  @"com.mydomain.myapp.Pack2", 
                  @"com.mydomain.myapp.Pack3",nil]]; 

productRequest.delegate = self; 
[productRequest start]; 
} 

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

NSArray *myProducts = response.products; 

NSLog(@"%d",[myProducts count]);//this prints 0 
for(SKProduct * product in myProducts) { 
    [products addObject:product]; 
} 
[request autorelease]; 


} 

    in my viewdidload: 


if([SKPaymentQueue canMakePayments]) { 
     NSLog(@"IN-APP:can make payments"); 
    } 
    else { 
     NSLog(@"IN-APP:can't make payments"); 
    } 

    /*load transaction history to see if the user already bought some packs*/ 
    [[SKPaymentQueue defaultQueue] addTransactionObserver:self]; 
    products = [[NSMutableArray alloc] init]; 
    NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString * path = [documentsDirectory stringByAppendingPathComponent: @"history.plist"]; 
    self.transactionHistory = [NSMutableArray arrayWithContentsOfFile: path]; 

    if(!transactionHistory) { 
     NSMutableArray *_transactionHistory = [[NSMutableArray alloc] init]; 
     self.transactionHistory = _transactionHistory; 
     [_transactionHistory release]; 
    } 
    //some other initializations here 
    [self requestProductData]; 

for (NSString *invalidProductId in response.invalidProductIdentifiers) 
    { 
     NSLog(@"Invalid product id: %@" , invalidProductId); 
    } 
//this returns 3 of my product id's 
+0

空或答案是“无效的产品ID”? – malinois

+0

在调试器中,如果我看看响应。有NSObject - isa和_internal - isa但就是这样。我甚至没有在调试器中看到response.products,当我说NSArray * myProducts = response.products; myProducts有0个元素 – tiw

+0

您的应用程序处于调试模式? – malinois

回答

6

你有一个无效的产品缺陷,所以用这个话题检查您的配置: Invalid Product IDs

  • 是否启用应用内购买你的App ID?
  • 您检查了您的产品的清仓待售吗?
  • 您是否提交了(并可选择拒绝)您的应用程序二进制文件?
  • 您的项目的.plist软件包ID是否与您的App ID匹配?
  • 您是否为新App ID生成并安装了新的供应配置文件?
  • 您是否使用此新配置文件将项目配置为代码签名?
  • 你是为iPhone OS 3.0或以上版本?
  • 在制作SKProductRequest时是否使用完整的产品ID?
  • 自从将产品添加到iTunes Connect后,您是否等了几个小时?
  • 您的银行信息是否在iTunes Connect上处于活动状态?
  • 您是否尝试过从设备中删除应用程序并重新安装?
  • 您的设备是否越狱?如果是这样,你需要恢复越狱为IAP工作。
+0

我是否必须提交我的产品以供他们审核才能生效? – tiw

+0

您是否阅读过链接? – malinois

+0

是的,我读过它。如果您在该页面上提及此问题:“您是否将产品添加到iTunes Connect后等了几个小时?”我的问题仍然有效。“将您的产品添加到ITunes Connect意味着它的状态是”准备提交“还是”准备好销售“? – tiw