简体   繁体   English

SFProductsRequest始终返回零

[英]SFProductsRequest always returning zero

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. 我已经在iTunes连接门户中的应用内购买管理器中创建了产品ID“ test1”。

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. 响应始终为0。我不明白我在做什么错。 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. 关于应用内购买的文档往往会造成混乱,iTunes连接中的整个过程并没有给我信心。

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. 但是,我决定不包括在应用程序购买中,而是让iTunes中的应用程序内购买连接以进行审查。 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 no野

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? 您是否为应用程序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? 您项目的.plist捆绑包ID是否与您的应用程序ID相匹配?
  • Have you generated and installed a new provisioning profile for the new App ID? 您是否为新的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? 您要针对iPhone OS 3.0或更高版本进行构建吗?
  • Are you using the full product ID when when making an SKProductRequest? 进行SKProductRequest时是否使用完整的产品ID?
  • Have you waited several hours since adding your product to iTunes Connect? 将产品添加到iTunes Connect之后,您是否已经等待了几个小时?
  • Are your bank details active on iTunes Connect? 您的银行详细信息在iTunes Connect上是否处于活动状态? (via Mark) (通过马克)
  • Have you tried deleting the app from your device and reinstalling? 您是否尝试过从设备中删除该应用并重新安装? (via Hector, S3B, Alex O, Joe, and Alberto) (通过Hector,S3B,Alex O,Joe和Alberto)
  • Is your device jailbroken? 您的设备越狱了吗? If so, you need to revert the jailbreak for IAP to work. 如果是这样,则需要还原越狱以使IAP正常工作。 (via oh my god, Roman, and xfze) (通过我的上帝,罗马人和xfze)
  • Are you logged out from real iTunes account? 您是否从真实的iTunes帐户注销?
  • Have you tried restarting device? 您是否尝试过重启设备?
  • Are you on Device? 您在设备上吗? (Will not work on Simulator) (将无法在模拟器上使用)

Credits go to Troy Brant 学分归特洛伊·布兰特Troy Brant)所有

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/ 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. 但是我必须说整个应用程序内购买是一个PITA-我的应用程序刚刚发布,我当然下载了它并检查了应用程序内购买屏幕。 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 ... 经过一番阅读后,即使所有内容都可以接受并准备出售,应用内购买产品仍然需要一段时间才能在线上获得-3小时后它终于可以工作了...

EDIT: 编辑:

You need to create the in-app purchase for your app and set it to clear for sale in itunes connect. 您需要为您的应用创建应用内购买并将其设置为在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? 您如何在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. 通常,您应该使用com.companyname.productname.purchasename名称,并且您从应用程序中请求的名称必须完全相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM