Example #1
0
        /// <summary>
        /// 初始化IAP 实例.
        /// </summary>
        /// <returns><c>true</c>, OK, <c>false</c> NG.</returns>
        private bool initIAPInstance()
        {
#if UNITY_IOS || UNITY_IPHONE
            this._IAPInstance = new IAPiOS();
#elif UNITY_ANDROID
            this._IAPInstance = new IAPAndroid();
#endif
            if (null == this._IAPInstance)
            {
                return(false);
            }

            // 绑定委托事件
            // 产品验证
            this._IAPInstance.OnProductsValidationStarted   = null;
            this._IAPInstance.OnProductsValidationCompleted = this.OnIAPProductsValidationCompleted;
            this._IAPInstance.OnProductsValidationFailed    = this.OnIAPProductsValidationFailed;

            // 购买
            this._IAPInstance.OnTransactionPurchasing = this.OnTransactionPurchasing;
            this._IAPInstance.OnTransactionCanceled   = this.OnIAPTransactionCanceled;
            this._IAPInstance.OnTransactionDeferred   = null;

            // 购买或者补单
            this._IAPInstance.OnTransactionPurchased = this.OnIAPTransactionPurchased;

            // 购买恢复
            this._IAPInstance.OnRestoreCompleted    = null;
            this._IAPInstance.OnTransactionRestored = this.OnIAPTransactionRestored;
            this._IAPInstance.OnRestoreFinished     = null;

            // 错误
            this._IAPInstance.OnFailed = this.OnIAPFailed;

            // 切换当前IAP实例
            IAPMsgSwitch.SetIAPInstance(this._IAPInstance);

            return(true);
        }
Example #2
0
        /// <summary>
        /// 初始化IAP 实例.
        /// </summary>
        /// <returns><c>true</c>, OK, <c>false</c> NG.</returns>
        private bool initIAPInstance()
        {
            // 创建IAP实例
            this._IAPInstance = this.CreateInstance();
            if (null == this._IAPInstance)
            {
                return(false);
            }

            // 绑定委托事件
            // 产品验证
            this._IAPInstance.OnProductsValidationStarted   = null;
            this._IAPInstance.OnProductsValidationCompleted = this.OnIAPProductsValidationCompleted;
            this._IAPInstance.OnProductsValidationFailed    = this.OnIAPProductsValidationFailed;

            // 购买
            this._IAPInstance.OnTransactionPurchasing = this.OnTransactionPurchasing;
            this._IAPInstance.OnTransactionCanceled   = this.OnIAPTransactionCanceled;
            this._IAPInstance.OnTransactionDeferred   = null;

            // 购买或者补单
            this._IAPInstance.OnTransactionPurchased = this.OnIAPTransactionPurchased;

            // 购买恢复
            this._IAPInstance.OnRestoreCompleted    = null;
            this._IAPInstance.OnTransactionRestored = this.OnIAPTransactionRestored;
            this._IAPInstance.OnRestoreFinished     = null;

            // 错误
            this._IAPInstance.OnFailed = this.OnIAPFailed;

            // 切换当前IAP实例
            IAPMsgSwitch.SetIAPInstance(this._IAPInstance);

            return(true);
        }