我知道它已經被問過:iPhone In App Purchase - response.products are still empty?應用程序內購買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
空或答案是「無效的產品ID」? – malinois
在調試器中,如果我看看響應。有NSObject - isa和_internal - isa但就是這樣。我甚至沒有在調試器中看到response.products,當我說NSArray * myProducts = response.products; myProducts有0個元素 – tiw
您的應用程序處於調試模式? – malinois