检测事件成功购买Unity3D

时间:2017-12-01 09:02:11

标签: c# unity3d in-app-purchase

我的游戏适用于IOS平台,当用户从Success purchase Popup ok 时,我需要关闭窗口并提示购买,但是如何检测此事件?或者按下购买时关闭此窗口?怎么回事?

enter image description here

1 个答案:

答案 0 :(得分:1)

我检测到在此方法中购买成功事件的时间 -

public PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs args)
    {

        if (String.Equals (args.purchasedProduct.definition.id, kProductIDSubscription, StringComparison.Ordinal)) {
            var builder = ConfigurationBuilder.Instance (StandardPurchasingModule.Instance ());
            var appleConfig = builder.Configure<IAppleConfiguration> ();
            DateTime? data = validate (appleConfig.appReceipt, kProductIDSubscription);
            if (data == null) {
                Debug.Log ("data then purchased");
            } else {
                Debug.Log ("Date: " + data);
            }
            if (data != null) {
                //Here is your code for success subscribed
                isPurchased = true;
            }
            #endif
        }   

        else {
            Debug.Log (string.Format ("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id));
        }
        return PurchaseProcessingResult.Complete;
    }