应用内购买响应。产品为空

发布于 2024-11-19 15:23:59 字数 2373 浏览 1 评论 0原文

我知道以前有人问过这个问题: iPhone In应用程序购买 - 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

I know it has been asked before: iPhone In App Purchase - response.products are still empty?

but I am also trying to implement an in app purchase and my response.products is empty.
My situation:

I uploaded and rejected my binary once.

But then I put the status back to waiting for upload again.(Does it matter?)

The status of all my in app purchase products are "Ready to Submit".

My production user is signed out. Test user not signed in yet.

-(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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

没有伤那来痛 2024-11-26 15:23:59

您遇到无效产品错误,因此请使用本主题检查您的配置:
无效的产品 ID

  • 您是否为您的应用 ID 启用了应用内购买?
  • 您是否已检查过您的产品是否已批准销售?
  • 您是否已提交(并可选择拒绝)您的应用程序二进制文件?
  • 您项目的 .plist 捆绑包 ID 与您的应用 ID 匹配吗?
  • 您是否为新的应用 ID 生成并安装了新的配置文件?
  • 您是否已将您的项目配置为使用此新的配置文件进行代码签名?
  • 您正在为 iPhone OS 3.0 或更高版本进行构建吗?
  • 您在发出 SKProductRequest 时是否使用完整的产品 ID?
  • 自从将产品添加到 iTunes Connect 后,您是否已经等待了几个小时?
  • 您的银行详细信息在 iTunes Connect 上有效吗?
  • 您是否尝试过从设备中删除该应用并重新安装?
  • 您的设备是否已越狱?如果是这样,您需要恢复越狱才能使 IAP 正常工作。

You have an invalid product error, so check your configuration with this topic:
Invalid Product IDs

  • Have you enabled In-App Purchases for your App ID?
  • Have you checked Cleared for Sale for your product?
  • Have you submitted (and optionally rejected) your application binary?
  • Does your project’s .plist Bundle ID match your App ID?
  • Have you generated and installed a new provisioning profile for the new App ID?
  • Have you configured your project to code sign using this new provisioning profile?
  • Are you building for iPhone OS 3.0 or above?
  • Are you using the full product ID when when making an SKProductRequest?
  • Have you waited several hours since adding your product to iTunes Connect?
  • Are your bank details active on iTunes Connect?
  • Have you tried deleting the app from your device and reinstalling?
  • Is your device jailbroken? If so, you need to revert the jailbreak for IAP to work.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文