SFProductsRequest 始终返回零
我正在尝试在免费应用程序中实现应用内购买。
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现这个问题最一致的解决方案是这个清单。它应该广泛传播,以避免任何人遇到同样的问题,这确实非常耗时且令人绝望:
积分转到 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:
Credits go to Troy Brant
看看这里,它回答了我所有的问题(而且该框架也很容易使用:-):
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.