First, thanks everyone.
首先,谢谢大家。
Prerequisite:I am providing consumable items in my application. product:
先决条件:我在申请中提供消耗品。产品:
- List item
- 项目清单
- User purchase the item by iap.
- 用户通过iap购买该商品。
- before my application received the updatedTrancactions(Transaction),Network is disconnected.
- 在我的应用程序收到updatedTrancactions(Transaction)之前,网络已断开连接。
So my server don't have data to verify the receipt. the user also can not get the "Virtual currency".
所以我的服务器没有数据来验证收据。用户也无法获得“虚拟货币”。
Would anyone tell me how to solve this problem,or give me some tip. Thanks very much.
有人会告诉我如何解决这个问题,或给我一些提示。非常感谢。
1 个解决方案
#1
1
its the standard client-server problem. In case the connection between client and server is severed (due to timeout or other reasons), common way to do it is to retry the request. But if your API calls are not Idempotent and calling an API multiple times can affect the state of your system that many times then we have to resort to do something more clever. Some options you have -
它是标准的客户端 - 服务器问题。如果客户端和服务器之间的连接被切断(由于超时或其他原因),常见的方法是重试请求。但是如果你的API调用不是幂等的并且多次调用API会多次影响你的系统状态,那么我们不得不求助于做一些更聪明的事情。你有一些选择 -
- Have a local database. When a purchase happens, then first update the state in you local DB. Late lazily sync the DB from client to server, I hear coredata or sqlite is excellent. User is not aware of this and since DB is local the UI will be extra snappy for the user.
- 有一个本地数据库。购买发生时,首先更新本地数据库中的状态。延迟懒惰地将DB从客户端同步到服务器,我听说coredata或sqlite非常好。用户不知道这一点,因为DB是本地的,UI对用户来说将是额外的活泼。
- Second approach is - in case of a failed HTTP call. You keep retrying till the call succeeds.
- 第二种方法是 - 在HTTP调用失败的情况下。你继续重试,直到通话成功。
- Incase the API is non-idempotent, then you need to have a concept of a token. i.e. a API call with the same token called multiple times is first checked on the server-side if the initial call was a success only if it was a failure execute again. ex. this is very important in banking solutions. Imagine multiple debits from your bank account due to timeouts and someone programmed to keep retrying!
- 如果API是非幂等的,那么你需要有一个令牌的概念。即,如果初始调用仅在失败时再次执行,则首先在服务器端检查具有多次调用相同令牌的API调用。恩。这在银行业解决方案中非常重要。想象一下,由于超时和有人编程继续重试,您的银行帐户会有多笔借记!
This is all I am able to think of right now. Give it a spin and tell us what worked for you...
这就是我现在所能想到的。给它一个旋转,并告诉我们什么对你有用...
#1
1
its the standard client-server problem. In case the connection between client and server is severed (due to timeout or other reasons), common way to do it is to retry the request. But if your API calls are not Idempotent and calling an API multiple times can affect the state of your system that many times then we have to resort to do something more clever. Some options you have -
它是标准的客户端 - 服务器问题。如果客户端和服务器之间的连接被切断(由于超时或其他原因),常见的方法是重试请求。但是如果你的API调用不是幂等的并且多次调用API会多次影响你的系统状态,那么我们不得不求助于做一些更聪明的事情。你有一些选择 -
- Have a local database. When a purchase happens, then first update the state in you local DB. Late lazily sync the DB from client to server, I hear coredata or sqlite is excellent. User is not aware of this and since DB is local the UI will be extra snappy for the user.
- 有一个本地数据库。购买发生时,首先更新本地数据库中的状态。延迟懒惰地将DB从客户端同步到服务器,我听说coredata或sqlite非常好。用户不知道这一点,因为DB是本地的,UI对用户来说将是额外的活泼。
- Second approach is - in case of a failed HTTP call. You keep retrying till the call succeeds.
- 第二种方法是 - 在HTTP调用失败的情况下。你继续重试,直到通话成功。
- Incase the API is non-idempotent, then you need to have a concept of a token. i.e. a API call with the same token called multiple times is first checked on the server-side if the initial call was a success only if it was a failure execute again. ex. this is very important in banking solutions. Imagine multiple debits from your bank account due to timeouts and someone programmed to keep retrying!
- 如果API是非幂等的,那么你需要有一个令牌的概念。即,如果初始调用仅在失败时再次执行,则首先在服务器端检查具有多次调用相同令牌的API调用。恩。这在银行业解决方案中非常重要。想象一下,由于超时和有人编程继续重试,您的银行帐户会有多笔借记!
This is all I am able to think of right now. Give it a spin and tell us what worked for you...
这就是我现在所能想到的。给它一个旋转,并告诉我们什么对你有用...