应用程序内购买 - 如何确定是否已进行购买? [英] In-App Purchase - How to determine if a purchase has already been made?

查看:417
本文介绍了应用程序内购买 - 如何确定是否已进行购买?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么如此难以找到如何做到这一点超出了我 - 所以也许我试图以错误的方式做到这一点 - 谁知道 - 很有希望你们中的一个,哈哈。

Why it's so hard to find out how to do this is beyond me - so maybe I am trying to do this the wrong way - who knows - well hopefully one of you, lol.

我有一个购买按钮(非消耗品)。如果购买成功,则更新NSUserDefaults purchase = YES并删除该按钮。这一切都很好。

I have a button that says 'Purchase' (for a non-consumable). If the purchase is successful then update NSUserDefaults purchased = YES and the button is removed. All good up to here.

现在,当用户删除应用程序并想要在新设备上重新安装或安装时,我想要显示的内容,在这些情况下,取代购买按钮是恢复按钮。将单击恢复按钮并调用restoreCompletedTransactions。对我来说似乎是合乎逻辑的 - 用户不希望看到他们已经购买的购买按钮。

Now when the user deletes the app and wants to reinstall or install on a new device then what I would like to show, in these cases, in place of the 'Purchase' button is a 'Restore' button. 'Restore' button would be clicked and restoreCompletedTransactions would be called. Seems logical to me - user doesn't want to see a 'Purchase' button - they have purchased already.

问题是NSUserDefaults购买= YES将无法重新获得 - 安装或新安装。所以我的问题是我如何确定之前是否购买了应用程序,因此我可以显示购买按钮或恢复按钮。有没有办法确定用户是否已经进行了此应用内购买?

Problem is NSUserDefaults purchased = YES will not be available on re-install or new install. So my question is how do I determine if the app has been purchased before so I can either display a 'Purchase' button or a 'Restore' button. Is there a way to determine if this in-app purchase has already been made by the user?

提前感谢Byron。

推荐答案

以后没有好办法将状态从一个应用安装转移到另一个应用安装。你也许可以滥用钥匙串,但你不应该这样做。

There is no good way to transfer state from one app install to another app install in the future. You might be able to abuse the keychain for this, but you shouldn't.

只是一直显示购买。在iOS上,这是处理这种情况的标准方法。人们习惯于看到购买按钮,即使他们之前购买过,他们也会明白这意味着什么。当然,你仍然需要一个恢复按钮。

Just show "Purchase" all the times. On iOS that's the standard way of handling this situation. People are used to see a purchase button even if they have purchased before, they will understand what that means. Of course you still need a restore button somewhere.

根据您使用的商店类型,您有两个选项来放置恢复按钮。

Depending on the kind of store you use you have two options to place the restore button.

如果您有类似商店的商店,例如一个列出所有产品的tableView,在tableView的末尾放置一个Restore Purchase单元格。以下是PCalc Lite的界面示例:

If you have a store like interface, e.g. a tableView which lists all your products, put a "Restore Purchase" cell at the end of your tableView. Here is the interface of PCalc Lite as an example:

如果您没有类似界面的商店,请在应用的设置部分放置一个按钮。迪斯科动物园就是这样做的:

If you don't have a store like interface, put a button in the settings section of your app. That's how Disco Zoo does it:

这篇关于应用程序内购买 - 如何确定是否已进行购买?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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