首页 文章

iPhone In App Purchase - response.products仍然是空的?

提问于
浏览
39

基本上,我已经尝试在测试应用程序中设置应用程序购买,然后再将其应用到我公司正在开发的应用程序中 . 我已经阅读了商店套件pdf和其他片段大约1000次,但产品仍然是空的 . 这正是我到目前为止所做的:

Setup test app and In App Purchase test items
我在iPhone开发人员中心的公司开发人员门户网站上为'Test App One'创建了一个新的应用程序ID . 我确保前缀为 com.mycompany.testappone ,以确保可以配置应用内购买 . 保持在App ID部分,我通过勾选'Enable In App Purchase'选项在应用购买中进行了配置 .

我在iTunes Connect中创建了“Test App One”,并完成了常规程序,但选择了“稍后上传二进制文件”并且没有提交审核,因为该应用程序什么都不做 . 当然,我们不必提交应用程序来审查这个工作?!然后,我点击管理应用内购买并创建了一个新产品ID为“test1”并批准它以便清除销售 .

Code
我在XCode中设置了一个名为 TestAppOne 的新项目,这里是我现在使用的唯一两个类:

TestAppOneAppDelegate.h:

#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>  

@interface TestAppOneAppDelegate : NSObject <UIApplicationDelegate, SKRequestDelegate, SKProductsRequestDelegate> {
    UIWindow *window;
}

TestAppOneDelegate.m:

#import "TestAppOneAppDelegate.h"

static NSString *kMyFeatureIdentifier1 = @"com.mycompany.testappone.test1";

@implementation TestAppOneAppDelegate
@synthesize window;

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

 [self requestProductData];
 [window makeKeyAndVisible]; 
}

- (void)requestProductData {
 NSLog(@"IN-APP:requestProductData");
 SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject:kMyFeatureIdentifier1]];
 request.delegate = self; 
 [request start];
 NSLog(@"IN-APP:requestProductData END");  
} 

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
 NSLog(@"IN-APP:productsRequest");
 NSArray *myProduct = response.products;
 NSLog(@"IN-APP:array count: %i", [myProduct count]);
 [request autorelease];
 NSLog(@"IN-APP:productsRequest END"); 
}

- (void)dealloc {
    [window release];
    [super dealloc];
}

@end

Testing on the device
我创建了一个沙箱测试帐户,并在iPhone上注销了我的iTunes帐户,但没有得到:'t log in with the test account as the documentation tells us to not do this until we are prompted at the purchasing stage. I then build the app and here is the log I'得到:

IN-APP:can make payments
IN-APP:requestProductData
IN-APP:requestProductData END
IN-APP:productsRequest
IN-APP:array count: 0
IN-APP:productsRequest END

任何人都可以告诉我,如果我已经离开了任何阶段,或者是否有任何我做错了 . 不幸的是,Apple似乎没有任何示例应用程序 .

9 回答

  • 1

    实际上我认为你必须提交二进制文件才能工作 .

    您可以将发布日期设置为遥远的未来 .

  • 5

    另一个经常被忽视的重要步骤是你需要确保你有一个iOS付费应用程序 Contract 设置,它位于iTunes连接的“ Contract ,税收和银行”部分下 . 首先,您必须单击请求按钮,然后您必须单击3设置按钮(联系信息,银行信息,税务信息)

  • 30

    检查是否存在无效的产品ID .

    - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
    
    for (NSString *invalidProductId in response.invalidProductIdentifiers)
        {
            NSLog(@"Invalid product id: %@" , invalidProductId);
        }
    }
    

    如果产品ID无效,请访问http://troybrant.net/blog/2010/01/invalid-product-ids/

    这是一个非常全面的问题清单 .

  • 8

    检查XCode中的Bundle Identifier(例如com.company.appname)是否与iTunes Connect中的Bundle Identifier匹配 .

    您无需提交二进制文件即可使用 .

  • 22

    只需删除设备上的应用程序,然后从XCode再次启动它 . 它解决了我的问题 .

    无需上传二进制文件,或在iTunes Connect中创建应用程序内购买后等待数小时 .

  • 2

    感谢alpere的回答,我发现我使用了错误的产品ID . 我认为 de.company.appname.PROFESSIONAL_LICENSEnot . 在我的情况下只使用 PROFESSIONAL_LICENSE (没有领先的包ID东西)工作:)

  • 0

    无需为InAppPurchase的Sandbox测试上传二进制文件 . 您只需在iTunesConnect中添加InAppPurchase项目,并将其置于“准备提交”(必须)状态 . 如果您提交以供审核,它将始终将ou response.product清空 .

  • 1

    尝试添加免费订阅产品 . 如果它出现在响应中,则代码中没有任何错误 . 由于免费订阅是唯一不需要协议,税务和银行业务的类型,如果它出现而其他类型没有,那么这是与您的 Contract 相关的问题 .

  • 18

    在我的情况下,原因是Apple错误地托管了内容 . 该产品仅在我关闭时才可用

相关问题