xcode Obj-C,Storekit restoreCompletedTransactions 返回零交易?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10120050/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Obj-C, Storekit restoreCompletedTransactions returns zero transactions?
提问by Jules
I'm having some problems restoring completed transactions.
我在恢复已完成的交易时遇到了一些问题。
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
I've added the observer mentioned in several examples, I've tried adding paymentQueueRestoreCompletedTransactionsFinished
and already have updatedTransactions
. paymentQueueRestoreCompletedTransactionsFinished
says I have zero transactions.
我已经添加了几个例子中提到的观察者,我已经尝试添加paymentQueueRestoreCompletedTransactionsFinished
并且已经有updatedTransactions
. paymentQueueRestoreCompletedTransactionsFinished
说我有零交易。
I can buy a product and if I try to buy again, it stops me and says I've already bought the product, using this code.
我可以购买产品,如果我再次尝试购买,它会阻止我并说我已经使用此代码购买了该产品。
SKPayment *payment = [SKPayment paymentWithProductIdentifier:productIdentifier];
[[SKPaymentQueue defaultQueue] addPayment:payment];
I thought maybe I had a problem with my bundle identifier, but that seems fine and the buy wouldn't work if it wasn't.
我想也许我的捆绑标识符有问题,但这似乎很好,如果不是,购买将无法正常工作。
I have been trying this on the device as well as the simulator, but this has the same result. Also, it doesn't make a difference If I'm using UK or US store.
我一直在设备和模拟器上尝试这个,但结果相同。此外,如果我使用英国或美国商店,这也没什么区别。
I'm really grasping at straws to find out why this doesn't work for me ?
我真的很想知道为什么这对我不起作用?
采纳答案by Malek_Jundi
try to do it like this and check the array count is it return zero also ?
尝试这样做并检查数组计数是否也返回零?
- (void) checkPurchasedItems
{
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}//You Call This Function
//Then this delegate Function Will be fired
- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
purchasedItemIDs = [[NSMutableArray alloc] init];
NSLog(@"received restored transactions: %i", queue.transactions.count);
for (SKPaymentTransaction *transaction in queue.transactions)
{
NSString *productID = transaction.payment.productIdentifier;
[purchasedItemIDs addObject:productID];
}
}