SFProductsRequest 始终返回零

发布于 2025-01-06 17:24:00 字数 2269 浏览 0 评论 0原文

我正在尝试在免费应用程序中实现应用内购买。

我在 itunes connect 门户的应用内购买管理器中创建了一个产品 ID“test1”。

当我通过以下方式发出产品请求时:

- (id)init {

     NSSet *productIdentifiers = [NSSet setWithObjects:
                             @"test1",
                             nil];

     if ((self = [self initWithProductIdentifiers:productIdentifiers])) {                

}

return self;

}

- (id)initWithProductIdentifiers:(NSSet *)productIdentifiers
{    
if ((self = [super init]))
{
    // Store product identifiers
    _productIdentifiers = [productIdentifiers retain];

    // Check for previously purchased products
    NSMutableSet * purchasedProducts = [NSMutableSet set];

    for (NSString * productIdentifier in _productIdentifiers)
    {
        BOOL productPurchased = [[NSUserDefaults standardUserDefaults] boolForKey:productIdentifier];

        if (productPurchased)
        {
            [purchasedProducts addObject:productIdentifier];
            NSLog(@"Previously purchased: %@", productIdentifier);
        }

        NSLog(@"Not purchased: %@", productIdentifier);
    }

    self.purchasedProducts = purchasedProducts;
}

return self;

}

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

NSLog(@"Received products results...");   
self.products = response.products;
self.request = nil;    

[[NSNotificationCenter defaultCenter] postNotificationName:kProductsLoadedNotification object:_products]; 

NSLog(@"%d",[self.products count]);
NSEnumerator *e = [self.products objectEnumerator];

id object;

while(object=[e nextObject])
{
    NSLog(@"item");
    NSLog(@"%s",(char*)object);
}

}

- (void)requestProducts {

self.request = [[[SKProductsRequest alloc] initWithProductIdentifiers:_productIdentifiers] autorelease];
_request.delegate = self;
[_request start];

}

响应始终为 0。我不明白我做错了什么。该代码来自教程。有关应用程序内购买的文档往往非常混乱,itunes connect 中的整个过程并没有给我信心。

我认为该应用程序需要在线销售才能使应用程序内购买发挥作用。不过,我决定不包含在应用内购买中,而是让itunes中的应用内购买连接进行审核。在审核过程中,该应用程序被拒绝,因为它应该与应用内购买一起进行测试。

但是,如果产品列表始终为零,我该如何测试应用内购买呢?

如果有更多经验的人可以给我建议,因为我已经对此感到疯狂了!

谢谢,

致以最诚挚的问候,

努诺

I'm trying to implement in app purchases in a free application.

I have created a productd id "test1" within the in app purchases manager in itunes connect portal.

When I make the product request in the following way:

- (id)init {

     NSSet *productIdentifiers = [NSSet setWithObjects:
                             @"test1",
                             nil];

     if ((self = [self initWithProductIdentifiers:productIdentifiers])) {                

}

return self;

}

- (id)initWithProductIdentifiers:(NSSet *)productIdentifiers
{    
if ((self = [super init]))
{
    // Store product identifiers
    _productIdentifiers = [productIdentifiers retain];

    // Check for previously purchased products
    NSMutableSet * purchasedProducts = [NSMutableSet set];

    for (NSString * productIdentifier in _productIdentifiers)
    {
        BOOL productPurchased = [[NSUserDefaults standardUserDefaults] boolForKey:productIdentifier];

        if (productPurchased)
        {
            [purchasedProducts addObject:productIdentifier];
            NSLog(@"Previously purchased: %@", productIdentifier);
        }

        NSLog(@"Not purchased: %@", productIdentifier);
    }

    self.purchasedProducts = purchasedProducts;
}

return self;

}

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

NSLog(@"Received products results...");   
self.products = response.products;
self.request = nil;    

[[NSNotificationCenter defaultCenter] postNotificationName:kProductsLoadedNotification object:_products]; 

NSLog(@"%d",[self.products count]);
NSEnumerator *e = [self.products objectEnumerator];

id object;

while(object=[e nextObject])
{
    NSLog(@"item");
    NSLog(@"%s",(char*)object);
}

}

- (void)requestProducts {

self.request = [[[SKProductsRequest alloc] initWithProductIdentifiers:_productIdentifiers] autorelease];
_request.delegate = self;
[_request start];

}

The response is always 0. I don't understand what am I doing wrong. This code came from a tutorial. The documentation regarding in app purchases tend to be quite confusing and the whole process in itunes connect doesnt give me confidence.

I thought the application needed to be online for sale for in app purchases to be working. However, I decided not to included in app purchases, but let the in app purchase in itunes connect for review. During the review process, the application was rejected because it should be working with the in app purchases for testing.

But how do I test in app purchases if the product listing comes always at zero?

If someone with more experience could give me an advice on this, since i'm already getting crazy with it!

Thanks,

With my best regards,

Nuno

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

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

发布评论

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

评论(2

一身骄傲 2025-01-13 17:24:00

我发现这个问题最一致的解决方案是这个清单。它应该广泛传播,以避免任何人遇到同样的问题,这确实非常耗时且令人绝望:

  • 您是否为您的 App ID 启用了应用内购买?
  • 您是否检查过您的产品的“Cleared for Sale”?
  • 您是否已提交(并可选择拒绝)您的应用程序二进制文件?
  • 您项目的 .plist Bundle ID 与您的 App ID 匹配吗?
  • 您是否为新的应用程序 ID 生成并安装了新的配置文件?
  • 您是否已将项目配置为使用此新的配置文件进行代码签名?
  • 您正在为 iPhone OS 3.0 或更高版本进行构建吗?
  • 您在发出 SKProductRequest 时是否使用完整的产品 ID?
  • 自从将产品添加到 iTunes Connect 后,您是否已经等待了几个小时?
  • 您的银行详细信息在 iTunes Connect 上有效吗? (来自 Mark)
  • 您是否尝试过从设备中删除该应用程序并重新安装? (来自 Hector、S3B、Alex O、Joe 和 Alberto)
  • 您的设备越狱了吗?如果是这样,您需要恢复越狱才能使 IAP 正常工作。 (来自天哪、Roman 和 xfze)
  • 您是否从真实的 iTunes 帐户中注销了?
  • 您是否尝试过重新启动设备?
  • 您在设备上吗? (不适用于模拟器)

积分转到 Troy Brant

The most coherent solution I found to this problem was this checklist. It should be wide spreaded in order to avoid anyone passing by the same problem which is really time consuming and desperating:

  • 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? (via Mark)
  • Have you tried deleting the app from your device and reinstalling? (via Hector, S3B, Alex O, Joe, and Alberto)
  • Is your device jailbroken? If so, you need to revert the jailbreak for IAP to work. (via oh my god, Roman, and xfze)
  • Are you logged out from real iTunes account?
  • Have you tried restarting device?
  • Are you on Device? (Will not work on Simulator)

Credits go to Troy Brant

陈独秀 2025-01-13 17:24:00

看看这里,它回答了我所有的问题(而且该框架也很容易使用:-):

http://blog.mugunthkumar.com/coding/iphone-tutorial-%E2%80%93-in-app-purchases/

但是我不得不说整个应用程序内购买的事情就是 PITA - 我的应用程序刚刚发布,当然我下载了它并检查了应用程序内购买屏幕。你猜怎么着,它完全是空的!

经过一番阅读后,似乎即使所有内容都被接受并准备出售,应用内购买产品仍然需要一段时间才能在线提供 - 3 小时后它终于起作用了......

编辑:

您需要创建内-为您的应用程序购买并在 itunes connect 中将其设置为清除销售。您无需上传屏幕截图或已对其进行审核,即可在开发模式下对其进行测试。

您如何在 itunes connect 中为购买命名?通常,您应该使用 com.companyname.productname.purchasename 名称,并且您从应用程序请求的名称必须完全相同。

Have a look here, that answered all of my questions (and the framework is simple to use, too :-):

http://blog.mugunthkumar.com/coding/iphone-tutorial-%E2%80%93-in-app-purchases/

But I have to say the whole in-app purchase thing is a PITA - my app just got released, and of course I downloaded it and checked the in-app purchase screen. Guess what, it came up completely empty!

After some reading up it seems that even if all is accepted and ready for sale, the in-app purchase products still need a while to become available online - after 3 hours it finally worked ...

EDIT:

You need to create the in-app purchase for your app and set it to clear for sale in itunes connect. You do not need to upload a screenshot yet or have it already reviewed in order to be able to test it in development mode.

How did you name the purchase in itunes connect? Normally you should use a com.companyname.productname.purchasename name, and the name you request from your app ha to be exactly the same.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文