iOS应用内购买非消耗品确定是新购买还是恢复
有没有办法查明用户何时购买非消耗品,是第一次购买还是已经购买并免费再次获得?
我检查了交易的 transactionState
、transactionDate
,但在这两种情况下,数据是相同的:
transactionState
: < code>SKPaymentTransactionStatePurchased(如果用户已经购买,则不是SKPaymentTransactionStateRestored
)transactionDate
:添加交易的日期到AppStore的支付队列。
Is there a way to find out when a user buys a non-consumable, if he buys it for the first time or has bought it already and gets it again for free?
I checked transactionState
, transactionDate
of the transaction, but in both cases the data is the same:
transactionState
:SKPaymentTransactionStatePurchased
(and notSKPaymentTransactionStateRestored
in case the user bought it already)transactionDate
: the date at which the transaction was added to the AppStore's payment queue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以检查在restoreTransaction方法之后将填充的交易数组,如果交易数组为空,则意味着用户第一次下载此升级。在另一种情况下,您将检查数组中的所有交易,并将
transaction. payment.productIdentifier
与所需的产品标识进行比较。如果不存在,则在交易数组中添加付款。对于非消耗性应用内购买,我使用了以下代码:
唯一的缺点是每次调用
restoreCompletedTransactions
时,都会弹出窗口要求您输入当前用户的密码。此解决方案可确保每次升级时购买窗口出现的次数不会超过 1 次,但每次您尝试购买其中一项时,所有升级都会恢复。You can check Array of transactions which will fill after restoreTransaction method and if Array of transactions is empty it means that user download this upgrade for the first time. In another case you'll check all transactions in Array and compare
transaction.payment.productIdentifier
with needful product identifire. If it doesn't exist add payment in transaction Array.For Non-Consumable In-App Purchase I used following code:
the only disadvantage is that every time you call
restoreCompletedTransactions
, window will pop up asking you to enter the password of the current user. This solution ensures that the buy window does not appear more than 1 time for each upgrade but all the upgrades will restore every time when you'll try to buy one of them.不确定,但也许您可以检查
transaction.originalTransacion
是否存在或是否不同。Not sure but maybe you can check if
transaction.originalTransacion
exists or if is different.