private static void DoRequestRating(RatingDialogContent content, Action <UserAction> callback) { if (!CanRequestRating()) { Debug.Log("Could not display the rating request popup because it was disabled, " + "or one or more display constraints are not satisfied."); return; } // If no custom content was provided, use the default one. if (content == null) { content = EM_Settings.RatingRequest.DefaultRatingDialogContent; } // Callback register customBehaviour = callback; #if UNITY_EDITOR Debug.Log("Request review is only available on iOS and Android devices."); #elif UNITY_IOS if (iOSNativeUtility.CanUseBuiltinRequestReview()) { // iOS 10.3+. iOSNativeUtility.RequestReview(); } else { // iOS before 10.3. MobileNativeAlert alert = MobileNativeAlert.ShowThreeButtonAlert( content.Title.Replace(RatingDialogContent.PRODUCT_NAME_PLACEHOLDER, Application.productName), content.Message.Replace(RatingDialogContent.PRODUCT_NAME_PLACEHOLDER, Application.productName), content.RefuseButtonText, content.PostponeButtonText, content.RateButtonText ); if (alert != null) { alert.OnComplete += OnIosRatingDialogCallback; } } if (!IsDisplayConstraintIgnored()) { // Increment the number of requests used this year. SetAnnualUsedRequests(DateTime.Now.Year, GetAnnualUsedRequests(DateTime.Now.Year) + 1); // Store the request timestamp Helper.StoreTime(LAST_REQUEST_TIMESTAMP_PPKEY, DateTime.Now); } #elif UNITY_ANDROID if (Instance != null) { return; // only allow one alert at a time } // Create a Unity game object to receive messages from native side Instance = new GameObject(RATING_DIALOG_GAMEOBJECT).AddComponent <MobileNativeRatingRequest>(); // Replace placeholder texts if any. var texts = new RatingDialogContent( content.Title.Replace(RatingDialogContent.PRODUCT_NAME_PLACEHOLDER, Application.productName), content.Message.Replace(RatingDialogContent.PRODUCT_NAME_PLACEHOLDER, Application.productName), content.LowRatingMessage.Replace(RatingDialogContent.PRODUCT_NAME_PLACEHOLDER, Application.productName), content.HighRatingMessage.Replace(RatingDialogContent.PRODUCT_NAME_PLACEHOLDER, Application.productName), content.PostponeButtonText, content.RefuseButtonText, content.RateButtonText, content.CancelButtonText, content.FeedbackButtonText ); // Show the Android rating request AndroidNativeUtility.RequestRating(texts, EM_Settings.RatingRequest); if (!IsDisplayConstraintIgnored()) { // Increment the number of requests used this year. SetAnnualUsedRequests(DateTime.Now.Year, GetAnnualUsedRequests(DateTime.Now.Year) + 1); // Store the request timestamp Helper.StoreTime(LAST_REQUEST_TIMESTAMP_PPKEY, DateTime.Now); } #else Debug.Log("Request review is not supported on this platform."); #endif }
/// <summary> /// Shows an alert with 3 buttons. /// </summary> /// <returns>The three buttons alert.</returns> /// <param name="title">Title.</param> /// <param name="message">Message.</param> /// <param name="button1">Button1.</param> /// <param name="button2">Button2.</param> /// <param name="button3">Button3.</param> public static MobileNativeAlert ShowThreeButtonAlert(string title, string message, string button1, string button2, string button3) { return(MobileNativeAlert.ShowThreeButtonAlert(title, message, button1, button2, button3)); }