Obj-C,Storekit restoreCompletedTransactions返回零事务? [英] Obj-C, Storekit restoreCompletedTransactions returns zero transactions?

查看:446
本文介绍了Obj-C,Storekit restoreCompletedTransactions返回零事务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在还原已完成的交易时遇到一些问题。

I'm having some problems restoring completed transactions.

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

我添加了几个例子中提到的观察者,我试过添加 paymentQueueRestoreCompletedTransactionsFinished ,并且已经拥有 updatedTransactions paymentQueueRestoreCompletedTransactionsFinished 表示我没有交易。

I've added the observer mentioned in several examples, I've tried adding paymentQueueRestoreCompletedTransactionsFinished and already have updatedTransactions. paymentQueueRestoreCompletedTransactionsFinished says I have zero transactions.

我可以购买产品,如果我再次尝试购买,

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 having 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 ?

推荐答案

尝试这样做并检查数组计数是否也返回零?

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];
  }
}

这篇关于Obj-C,Storekit restoreCompletedTransactions返回零事务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆