如何在iOS模拟器或设备上测试IAP(应用程序内购买)?

问题描述:

我按照Ray Wenderlich教程书实现了一个简单的非消费类应用程序内购买机制。

I've implemented a simple non-consumable in-app purchase mechanism by following the Ray Wenderlich tutorial book.

当我的应用程序启动时,我发起了产品信息请求:

When my app starts, I initiate a product info request:

self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
_productsRequest.delegate = self;
[_productsRequest start];

创建SKProductRequest。它有一个内存地址但没有其他任何事情发生。没有任何委托方法被调用:

The SKProductRequest gets created. It has a memory address but nothing else happens. None of the delegate methods gets called:

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
    NSLog(@"Product info received...");
    NSArray *products = response.products;
    for (SKProduct *product in products) {
        NSLog(@"ID: %@, title:%@, (%f)", product.productIdentifier, product.localizedTitle, product.price.floatValue);
    }

    self.productsRequest = nil;
}

- (void)request:(SKRequest *)request didFailWithError:(NSError *)error {
    NSLog(@"Failed to load list of products");
    self.productsRequest = nil;
}

我检查过两次:


  • 应用程序在iTunes Connect中完全设置。

  • ITC中的应用程序状态为准备上传

  • 添加了一个非消耗性IAP。

  • ITC中IAP产品的状态为准备提交

  • 应用程序ID为com.mycompany。 myapp既适用于app,也适用于plist。检查了两次。

  • IAP使用com.mycompany.myapp.productname(对请求使用完全相同的ID)。

  • 创建了一个测试用户帐户ITC。

  • 还没有提交给Apple。

  • 我的Mac可以访问互联网。

  • 没有控制台或屏幕上的其他消息。

  • App fully set-up in iTunes Connect.
  • Status of app in ITC is "Prepare for Upload"
  • One non-consumable IAP added.
  • Status of IAP product in ITC is "Ready to Submit"
  • App ID is com.mycompany.myapp both for the app and in the plist. Checked twice.
  • IAP uses com.mycompany.myapp.productname (using exact same ID for the request).
  • Created a test user account in ITC.
  • Nothing submitted to Apple yet.
  • My Mac has internet access.
  • There are no other messages in the console or on screen.

Ray Wenderlich书中没有提到除此之外我必须做任何其他事情。

The Ray Wenderlich book doesn't mention I must do anything else besides this.

只有一次我看到-didFailWithError:在设备上调用我的委托,但它再也没有出现过。我的代表在设备或模拟器上都没有被调用。我让它运行几分钟而没有任何回复。

Only once I saw a -didFailWithError: call to my delegate on the Device, but it never again appeared. My delegate doesn't get called both on device or simulator. I let it run for minutes with no response at all.

iTunes Connect发出这个令人困惑的警告:

iTunes Connect gives this confusing warning:


您的首次应用程序内购买必须使用新的应用程序
版本提交。从版本
详细信息页面的应用程序内购买部分中选择它们,然后单击准备上传二进制文件。

Your first In-App Purchase(s) must be submitted with a new app version. Select them from the In-App Purchases section of the Version Details page and then click Ready to Upload Binary.

是这是在能够测试应用内购买之前需要的吗?

Is this required prior to being able to test In-App Purchases?

在当前版本的Xcode 5.0(5A1413)中,In -App购买将无法在iOS模拟器中使用。

In the current version of Xcode 5.0 (5A1413), In-App purchases will not work in the iOS simulator.


StoreKit(应用程序内购买)在模拟器中不起作用。 13962338

StoreKit (In-App purchases) will not work in the Simulator. 13962338

来源:Xcode 5.0发行说明>已知问题> iOS模拟器 https://developer.apple.com/library /ios/releasenotes/DeveloperTools/RN-Xcode/xc5_release_notes/xc5_release_notes.html#//apple_ref/doc/uid/TP40001051-CH2-SW303

Source: Xcode 5.0 Release Notes > Known issues > iOS Simulator https://developer.apple.com/library/ios/releasenotes/DeveloperTools/RN-Xcode/xc5_release_notes/xc5_release_notes.html#//apple_ref/doc/uid/TP40001051-CH2-SW303