Пример #1
0
        public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
        {
            if (showResult == ShowResult.Finished)
            {
                var currentTime = DateTime.Now;
                var endTime     = EncryptedGlobalPreferences.GetPrimitive("advanced_set_end_time", currentTime);
                if (endTime < currentTime)
                {
                    endTime = currentTime;
                }

                EncryptedGlobalPreferences.SetPrimitive("advanced_set_end_time", endTime.Value.AddMinutes(30));

                Debug.Log("FINISH: FINISHED");
            }
            else if (showResult == ShowResult.Skipped)
            {
                Debug.Log("FINISH: SKIPPED");
            }
            else if (showResult == ShowResult.Failed)
            {
                Debug.LogWarning("FINISH: FAILED");
            }

            AdFinished?.Invoke(placementId, showResult);
        }
Пример #2
0
        public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs purchaseEvent)
        {
            if (_AllProducts.Contains(purchaseEvent.purchasedProduct.definition.id, StringComparer.Ordinal))
            {
                Debug.Log($"ProcessPurchase: PASS. Product: '{purchaseEvent.purchasedProduct.definition.id}'");

                var match = Regex.Match(purchaseEvent.purchasedProduct.definition.id, @"(\w+)_set$");

                if (match.Success && match.Groups[1].Success)
                {
                    AndroidNativeWrapper.CallMethod("ShowToast", new object[] { purchaseEvent.purchasedProduct.definition.id, 0 });
                    EncryptedGlobalPreferences.SetPrimitive($"{match.Value}_activated", true);
                    EncryptedGlobalPreferences.SetPrimitive($"any_set_activated", true);
                }
                else
                {
                    /*
                     * switch (purchaseEvent.purchasedProduct.definition.id)
                     * {
                     *
                     * }
                     */
                }
            }
            else
            {
                Debug.Log($"ProcessPurchase: FAIL. Unrecognized product: '{purchaseEvent.purchasedProduct.definition.id}'");
            }

            return(PurchaseProcessingResult.Complete);
        }