取消在应用程序购买中不发送异常,如示例所示

问题描述:

我在商店中有一个应用程序内购买选项。 我使用了这个代码示例...

I have an app in the store that has an in app purchase option.  I used this code sample...

BuyFeature1() {
    if (!licenseInformation.ProductLicenses["featureName"].IsActive)
    {
        try
								{
            // The customer doesn't own this feature, so 
            // show the purchase dialog.
								
            await CurrentProductSimulator.RequestProductPurchaseAsync("featureName");
            // the in-app purchase was successful
        }
        catch (Exception)
        {
            // The in-app purchase was not completed because the
            // customer canceled it or an error occurred.
        }
    } 
    else
    {
        // The customer already owns this feature.
    }
}


来自
这个
如何记录。 问题是如果用户单击取消而不是购买,则不会返回异常,因为它表示它在代码示例中,因此我最终显示消息"应用内购买成功"。即使它不是 。 
由于ProductLicenses未更新,因此该功能无法启用,但我不希望每次取消时都显示错误的消息。 当我使用CurrentAppSimulator时它工作正常。


RBL3

from this how to document.  The problem is if the user clicks Cancel instead of Buy an exception is not returned as it says it is in the code sample so I end up displaying the message "the in-app purchase was successful" even though it wasn't.  The feature does not enable since the ProductLicenses does not update but I don't want to be displaying the wrong message every time it's canceled.  It worked fine when I was using the CurrentAppSimulator.


RBL3

您可以使用此功能的收据退货。根据
文档
,你必须使用:

// result is an xml string that contains the feature that is just purchased.
var result = await CurrentProductSimulator.RequestProductPurchaseAsync("featureName", true);




希望有帮助......


hope it helps...