有没有办法知道购买哪个iTunes帐户? - iOS [英] Is there any way to know purchase made by which iTunes account? - iOS

查看:86
本文介绍了有没有办法知道购买哪个iTunes帐户? - iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用提供应用内购买非耗材类型。该应用程序具有登录功能。是否可以根据登录用户购买我的应用程序?

My app provides an in-app-purchase non-consumable type. The app has log in facility. Is it possible to make purchase based on logged in user to my app?

我知道这听起来很尴尬。让我指出问题。

I know it sounds awkward. Let me specify the problem.

设备已经在iTunes商店登录了用户。那时,当我的应用程序第一次安装到设备时,任何用户都可以使用凭据登录我的应用程序。考虑一下,他做了一些购买并从应用程序注销。现在,另一个用户登录到应用程序,并且在应用程序购买后无法使用以前用户可用的工具。但是,如您所知,基于iTunes商店帐户购买非消费品(每个帐户只能购买一个非消费品)。我尝试过以下方式..

The device has a already logged in user at iTunes store. At that time, when my app gets install to device for first time, any user can login with credentials to my app. Consider, he made some purchase and log out from the app. Now, another user logged in to the app and can't use facilities available for previous user after in app purchase. But as you know non-consumable product purchase based on iTunes store account (only one non-consumable product can be purchased for each account). I have tried by following way..


  1. 将用户ID存储到iCloud,但我不知道哪个iTunes帐户购买了。因此,我无法显示正确的消息您应该使用不同的iTunes帐户登录才能购买。

  1. Store user id to iCloud, but I don't know by which iTunes account that purchase was made. So, I couldn't display proper message "You should log in with different iTunes account to make purchase".

在Android中,使用应用内结算v3,开发人员有效负载字符串可以与购买请求一起发送。在对该购买进行查询时,也会返回此字符串。因此,这可用于识别进行购买的用户。在iOS中有类似的东西吗?

In android, with the In-app Billing v3, a developer payload string can be sent along with the purchase request. This string is also returned when a query is made for that purchase. So, this can be used to identify the user who made the purchase. Is there anything similar available in iOS?


推荐答案

从iOS 7开始, SKMutablePayment 有一个 applicationUsername 属性,可以在付款时设置。并且, SKPaymentQueue 具有 restoreCompletedTransactionsWithApplicationUsername:方法(link)

As of iOS 7, SKMutablePayment has an applicationUsername property that can be set when a payment is made. And, SKPaymentQueue has the restoreCompletedTransactionsWithApplicationUsername: method (link).

Apple的指导是散列您的服务器端用户ID,并在购买和恢复时将其传递出去。因此,在您的情况下,如果iTunes用户A购买该产品,它将被绑定到该购买者的服务器端用户ID。然后,如果iTunes用户B尝试恢复,则恢复将失败,因为它们仍然会传递相同的服务器端用户ID。

Apple's guidance is to hash your server-side user ID and pass that up on purchase and restore. So, in your case, if iTunes User A purchases the product it will be bound to your server-side user ID for that purchaser. Then, if iTunes User B attempts to restore, restoration will fail, because they would still be passing up the same server-side user ID.

您还必须跟踪(在服务器上)您的服务器端用户ID已购买产品。否则,如果iTunes用户B尝试恢复,则需要知道他们使用其他iTunes帐户登录设备之间的区别,并且他们从未购买过。当然,您还希望阻止同一服务器端用户在不同的iTunes帐户下购买产品两次。

You'll also have to track (on the server) that your server-side user ID has purchased the product. Otherwise, if iTunes User B attempts to restore you'll need to know the difference between they having logged into the device with a different iTunes account and they having never purchased. And of course, you'll also want to prevent the same server-side user from purchasing the product twice, under different iTunes accounts.

警告:


  • 如果您已经在生产中进行了购买,这很可能无法使用。

  • iOS 7 +

  • 我上面提到的已购买场景。

这篇关于有没有办法知道购买哪个iTunes帐户? - iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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