应用内购买响应。产品为空
我知道以前有人问过这个问题: 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您遇到无效产品错误,因此请使用本主题检查您的配置:
无效的产品 ID
You have an invalid product error, so check your configuration with this topic:
Invalid Product IDs