问题描述
我正在恢复购买,所以我几乎没有怀疑
I am working on restoring purchases, So I have few doubts
1)如何显示恢复按钮
1) How to show restore button
我已在左上角显示它,点击它我调用此函数
I have shown it on top left corner, and on click of it I call this function
- (IBAction)restorePurchases:(id)sender
{
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue]restoreCompletedTransactions];
}
但是如果用户没有购买anyItem或者如果用户购买了一个项目但没有删除并重新安装应用程序,是否仍然需要显示restoreButton,如果是,点击它应该是它的行为。
But What if the user has not purchased anyItem or what if the user has purchased an item but not deleted and reinstalled the app, Whether I still need to show the restoreButton, and if yes, on click of it what should be its behaviour.
2)现在,如果我购买了一个项目并删除了应用程序并重新安装了应用程序,并点击了恢复按钮,则会调用此功能
2) Now, If I have made a purchase of an item and delete the app and reinstall the app, and click on restore button, it calls this function
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
**case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];**
default:
break;
}
}
}
但现在,假设我不这样做但anyitem只需单击恢复按钮,它会询问我的苹果ID,输入苹果ID后,没有任何反应,它没有调用上述功能,我想知道为什么会发生这种情况。
But now, suppose I dont but anyitem and simply click restore button, it asks me for my apple Id, after entering apple Id, nothing happens, It doesnt call the above function, I want to know why this is happening.
另外,我想向用户显示一条消息,表示没有要恢复的项目,所以我该怎么做。
Also, I want to display a message to user that there are no items to restore, so how can I do that.
我搜索了这个和他们是一个委托函数,如果没有要复制的交易,将被调用
I searched for this and their is one delegate function which will be called,if there are no transactions to retore
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
}
我所做的是在这里我检查了是否有没有要恢复的项目,我将显示没有要恢复的项目,我是否正确的方法。
What I have done is that here I have checked if there are no items to restore, I will display as no items to restore, whether I am right in this approach.
问候
Ranjit
RegardsRanjit
推荐答案
直接来自商店套件头文件
//异步。将当前用户
的已完成事务添加回队列以重新完成。用户将被要求
身份验证。观察者将收到0或更多
-paymentQueue:updatedTransactions:,然后是-paymentQueueRestoreCompletedTransactionsFinished:成功或-paymentQueue:restoreCompletedTransactionsFailedWithError:失败时。在部分成功的情况下,某些交易可能仍然是
交付。
- (void)restoreCompletedTransactions __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
这篇关于在iOS中恢复购买的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!