iOS在应用程序购买 – 没有收到产品

我正在尝试将应用程序内购买添加到我的应用程序中,遵循以下描述的技术:

iOS 6教程中的应用内购买简介

我已经通过iTunes连接添加了一个产品,它有一个像这样设置的ID:

com.mycompany.myapp.myproduct1 

捆绑ID(在p列表中以及在app store中指定)设置如下:

  com.mycompany.myapp 

我使用教程IAHelper的帮助类来处理购买function(下面显示的相关代码)。 它也有一个子类,主要用于将应用内产品的ID添加到IAHelper的产品ID列表中。

为了testing代码,我创build了一个标签为“show products”的button,它调用了这个方法:

 - (IBAction) showProducts { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(productsLoaded:) name:kProductsLoadedNotification object:nil]; Reachability *reach = [Reachability reachabilityForInternetConnection]; NetworkStatus netStatus = [reach currentReachabilityStatus]; if (netStatus == NotReachable) { NSLog(@"No internet connection!"); } else { if ([InAppMyAppAPHelper sharedHelper].products == nil) { // here's where it calls the helper class method to request the products [[InAppMyAppAPHelper sharedHelper] requestProducts]; self.hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; _hud.labelText = @"Loading vocabulary..."; [self performSelector:@selector(timeout:) withObject:nil afterDelay:30.0]; } } } 

这是从上面所述的iTunesConnect请求产品的方法:

 - (void)requestProducts { self.request = [[[SKProductsRequest alloc] initWithProductIdentifiers:_productIdentifiers] autorelease]; _request.delegate = self; [_request start]; } 

(请注意,以“_”开头的variables指的是相同名称的实际variables不包含每个合成语句的下划线)

最后,这是在收到响应时得到通知的方法(在IAHelper中):

 - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response { NSLog(@"IAHelper, received products results..."); self.products = response.products; self.request = nil; // Here's the loop to list the products received for (id product in _products){ NSLog(@"IAHelper, received product is: %@", product); } [[NSNotificationCenter defaultCenter] postNotificationName:kProductsLoadedNotification object:_products]; } 

在上面,日志语句显示方法被调用,但是打印接收到的产品的循环没有列出任何东西。

所以它看起来好像在iTunes连接中找不到产品。 然而,我已经在那里build立了一个产品,产品的id和bundle id一样,加上产品标识符

 bundle id: com.mycompany.myapp product id: com.mycompany.myapp.product1 

我已经检查了几次。

我注意到iTunes列出了ad-in产品的状态为“准备提交”。 有没有额外的步骤,我需要使其可用?

总的来说,我做错了什么?

我遇到了类似的问题。 阅读了苹果的技术说明之后,以下是一些需要注意 /检查的步骤:

  • 创build一个唯一的App ID
  • 为此应用ID启用应用内购买
  • 在您的设备上生成并安装新的configuration文件
  • 更新Xcode中的包ID和代码签名configuration文件
  • 检查您的项目的.plist软件包ID是否与您的App ID匹配
  • 完成您的合同,税务和银行信息。 你需要一个有效的合同

正如官方文档中提到的,不需要提交二进制文件,也不提交应用内购买的截图。 我在各种博客上看到了很多关于这方面的误导信息。

在检查你已经解决了这个列表中的每个点后,删除你的应用程序并重新安装它。

我基本上错过了两件事情:正确设置我的合同,为我的付费应用程序,我没有安装新的供应configuration文件在我的设备上。 可能是你的问题?

获取没有有效的产品返回productsRequest:didReceiveResponse是一个众所周知的问题。 有很多原因,有些在TN2259特别是FAQ#6中给出。 通常问题是,应用程序没有指向自己的沙箱。 通常这是因为开发人员没有按顺序执行这三件事情:1)删除应用程序的旧版本(删除,而不是覆盖)2)使用设置应用程序注销设备上的应用程序商店3)运行应用程序Xcode在设备上(而不是模拟器),只有在app store询问时才能使用testing用户login商店。

当我在模拟器上testing应用程序时,我有同样的问题。试试它在设备和它的工作。

如果您正在模拟器上进行testing,请按照以下链接中的步骤操作: https : //developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/DevelopingwithStoreKit/DevelopingwithStoreKit.html#//apple_ref/doc/uid / TP40008267-CH103-SW1

我有一个类似的问题。 我使用在另一个应用程序中工作的代码,所以它应该已经工作,但我得到一个无效的产品ID错误,没有收到任何结果。 原来,这是一个时间问题。 我正在尝试处理返回的产品之前,他们已被返回到应用程序,所以错误是终止应用程序之前,产品有时间加载! 我的程序逻辑是:

  • 用户打开商店视图和IAP产品加载
  • UITableView加载了一个产品列表(但是来自本地的数组)
  • 用户点击表格单元格上的购买button – 如果发生得太快,实际的产品还没有返回 – 应用程序崩溃

对我来说,回答是从返回的产品中build立表格(首先应该对我来说是显而易见的!),所以用户在正确加载之前无法继续

回答Swift项目有同样的错误:

我的错误在这里:

 //identifiers: [String] let productIDs = Set(arrayLiteral: identifiers) as Set<NSObject>! let request = SKProductsRequest(productIdentifiers: productIDs) 

但是这段代码会导致代码= 0的错误信息无法连接到iTunes Store。 让我们看看SKProductsRequestinput参数types:

SKProductsRequest(productIdentifiers: Set<NSObject>!)

所以,上面的代码看起来合法。 但它不! Swift Set是个问题,考虑到在input参数中我们看到了Swift Set!

迭代一些IAP课程时find答案。 这是工作代码:

 let productIDs = NSSet(array: identifiers) let request = SKProductsRequest(productIdentifiers: productIDs as! Set<NSObject>) 

现在你必须使用NSSet,尽pipeSwift Set已经可用了,并且它被设置为input参数types! 看起来像是一个bug,我会发一个bug。

我们被困在试图在模拟器上运行它的同样的问题一段时间。

在真正的Apple TV设备(通过USB连接)上试用后,我们开始获得有效的产品ID。

然后,您只需要在您的代码上申请支付这些产品中的一种,并且您应该能够被要求进行身份validation(使用沙盒用户)并批准您在Apple TV上的购买。

我想我可能在这里find了答案。

这个来自应用内购买网页的措辞让我感到:

 The first In-App Purchase for an app must be submitted for review at the same time that you submit an app version. You must do this on the Version Details page. Once your binary has been uploaded and your first In-App Purchase has been submitted for review, additional In-App Purchases can be submitted using the table below. 

如果你没有testing应用程序内购买代码,你可以做些什么来避免提交应用程序进行审查,即提交审查,然后立即自行拒绝。 这使它成为“开发者拒绝”的地位。

比你可以添加你的产品,根据博客,

 After saving the product, just choose the “Submit with app binary” option. This will tie the product to the app binary, so when you finally submit the 100% complete app binary, the product will be submitted as well.