android-来自Google Play的应用内结算广播顺序错误? (静态测试)

android-来自Google Play的应用内结算广播顺序错误? (静态测试),第1张

概述应用内结算的Android文档在以下方面似乎很清楚.在REQUEST_PURCHASE之后,您将显示具有未决意图的结帐(很好,没有问题),然后用户与结帐进行交互并按下“购买”按钮(在这种情况下,我使用的是静态商品IDandroid.test.purchased).现在,我的广播接收器应该收到RESPONSE_CODE,然后收到IN

应用内结算的Android文档在以下方面似乎很清楚.在REQUEST_PURCHASE之后,您将显示具有未决意图的结帐(很好,没有问题),然后用户与结帐进行交互并按下“购买”按钮(在这种情况下,我使用的是静态商品ID androID.test.purchased).

现在,我的广播接收器应该收到RESPONSE_CODE,然后收到IN_APP_NOTIFY.嗯,那没有发生.有时我会首先得到响应,但是经常在通知后得到它.

下面引用的AndroID Doc部分中第二个强调的部分是为什么这是一个问题.如果我在收到购买请求的异步响应时将我的应用程序状态更新为“待处理”,因为文档似乎表明我应该这样做,那么如果通知发出后我的应用程序处于待处理状态,则该响应是否到来.是否应该说“当您从即时同步响应收到result_ok时”?

是Goole Play的错误吗(我手机上的Google Play版本为3.5.15,AndroID os版本为2.2)?我误会文档了吗? Docs只是错误的吗?静态测试产品是否有问题?还有其他问题吗?请注意,就我而言,一切都在UI线程中运行,因此这不是线程问题.

典型的非工作运行的日志输出显示在底部.

AndroID文档的相关部分(重点是我的):

Handling broadcast intents

A REQUEST_PURCHASE request also triggers two asynchronous responses
(broadcast intents). First, the Google Play application sends a
RESPONSE_CODE broadcast intent, which provIDes error information about
the request. If the request does not generate an error, the
RESPONSE_CODE broadcast intent returns RESulT_OK, which indicates that
the request was successfully sent. (To be clear, a RESulT_OK response
does not indicate that the requested purchase was successful; it
indicates that the request was sent successfully to Google Play.)

Next, when the requested transaction changes state (for example, the
purchase is successfully charged to a credit card or the user cancels
the purchase), the Google Play application sends an IN_APP_NOTIFY
broadcast intent. This message contains a notification ID, which you
can use to retrIEve the transaction details for the REQUEST_PURCHASE
request.

Note: The Google Play application also sends an IN_APP_NOTIFY for
refunds. For more information, see Handling IN_APP_NOTIFY messages.

Because the purchase process is not instantaneous and can take several
seconds (or more), you must assume that a purchase request is pending
from the time you receive a RESulT_OK message until you receive an
IN_APP_NOTIFY message for the transaction. While the transaction is
pending, the Google Play checkout UI displays an “Authorizing
purchase…” notification; however, this notification is dismissed
after 60 seconds and you should not rely on this notification as your
primary means of conveying transaction status to users. Instead, we
recommend that you do the following:

我的日志中的示例未按预期顺序进行:

MAKING REQUEST: PurchaseRequestEXECUTING REQUEST: PurchaseRequestIMEDIATE RESPONSE IN: PurchaseRequest, IS RESulT_OKREQUEST ID: 1814990809059790249, PurchaseRequestReceiver: NotifyNotify String in IN_APP_NOTIFY intent: androID.test.purchasedPROCESSING NOTIFICATIONMAKING REQUEST: PurchaseinformationRequestEXECUTING REQUEST: PurchaseinformationRequestIMEDIATE RESPONSE IN: PurchaseinformationRequest, IS RESulT_OKREQUEST ID: 602248989635492868, PurchaseinformationRequestReceiver: purchase state changedPROCESSING PURCHASE_STATE_CHANGEnewestMarketPurchaseState = PURCHASEDSetState on product 'Enterprise'. Message: PURCHASEDMAKING REQUEST: ConfirmNotificationsRequestEXECUTING REQUEST: ConfirmNotificationsRequestIMEDIATE RESPONSE IN: ConfirmNotificationsRequest, IS RESulT_OKREQUEST ID: 693394902887436727, ConfirmNotificationsRequestReceiver: Response Code = RESulT_OKReceiver: Response Code requestID = 602248989635492868PROCESSING RESPONSEASYNCH RESPONSE IN: PurchaseinformationRequest, IS RESulT_OKReceiver: Response Code = RESulT_OKReceiver: Response Code requestID = 1814990809059790249PROCESSING RESPONSEASYNCH RESPONSE IN: PurchaseRequest, IS RESulT_OKSetState on product 'Enterprise'. Message: PURCHASE PENDINGReceiver: Response Code = RESulT_OKReceiver: Response Code requestID = 693394902887436727PROCESSING RESPONSEASYNCH RESPONSE IN: ConfirmNotificationsRequest, IS RESulT_OKConfirm Notifications Request returned asynch OK

解决方法:

我也遇到了同样的问题.根据问题Are Android broadcasts received in order?的答案,不能绝对保证将按发送顺序接收到意图.他们通常这样做,但不一定.因此,即使Google Play正确订购了它们,它们仍然可以按其他顺序到达.

我认为,唯一的解决方案是不假设RESPONSE_CODE到达的时间.在这方面,AndroID文档确实对我来说确实是错误的.响应代码应该应该通过回调而不是广播来实现.我不得不承认Google有时会变得很粗心.

总结

以上是内存溢出为你收集整理的android-来自Google Play的应用内结算广播顺序错误? (静态测试)全部内容,希望文章能够帮你解决android-来自Google Play的应用内结算广播顺序错误? (静态测试)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1074037.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存