1 using UnityEngine;
2 using
System.Collections;
3
4 public
class Rater : MonoBehaviour
5 {
6     
// Use this for initialization
7     
void Start()
8     {
9         
//Rater
10         showAPIRaterFinalX();
11
12         
//Delete Counter Just for testing purpose make sure to comment this
13         
//PlayerPrefs.DeleteAll();
14     }
15
16     
//Create Rate URL
17     
string getRateURL()
18     {
19         
string appId = "com.ZeeMelApps.KittenRunner";//GooglePlay, Amazon, Samsung
20         
//string appId = "49058ZeeMelApps.EndlessKittenRun_bc0tz99paqz1e";//Windows 10
21         
//string appId = "1185855724";//Apple
22
23         
string rateURL = "market://details?id=" + appId;//Google Play
24         
//string rateURL = "amzn://apps/android?p=" + appId;//Amazon
25         
//string rateURL = "samsungapps://ProductDetail/" + appId;//Samsung
26         
//string rateURL = "ms-windows-store:REVIEW?PFN=" + appId;//Windows 10
27         
//string rateURL = "https://itunes.apple.com/app/id" + appId;//Apple
28
29         
return rateURL;
30     }
31
32     
int initialLaunchCount = 5;
33     
int remindLaterLaunchCount = 10;
34     
void rateAppShow()
35     {
36         
// Show Rater Dialog
37         raterObj.SetActive(
true);
38     }
39
40     
public void btnRatingRateIt()
41     {
42         
//Rate It
43         PlayerPrefs.SetString(
"CounterRater", "100000");
44
45         
//Open Rate URL
46         Application.OpenURL(getRateURL());
47
48         
//Hide Rate It
49         raterObj.SetActive(
false);
50     }
51
52     
public void btnRatingRemindMeLater()
53     {
54         
//Remind Me Later
55         PlayerPrefs.SetString(
"CounterRater", remindLaterLaunchCount.ToString());
56
57         
//Hide Rate It
58         raterObj.SetActive(
false);
59     }
60
61     
bool canShowRateIt()
62     {
63
64         
bool canGo = false;
65
66         
string fTIme = "";
67         
try
68         {
69             fTIme = PlayerPrefs.GetString(
"FirstTimeRater");
70         }
71         
catch (System.Exception)
72         {
73             PlayerPrefs.SetString(
"FirstTimeRater", "no");
74             PlayerPrefs.SetString(
"CounterRater", initialLaunchCount.ToString());
75         }
76
77         
if (fTIme == "no")
78         {
79             
string counterS = PlayerPrefs.GetString("CounterRater");
80             
int counter = int.Parse(counterS);
81             counter--;
82             
if (counter <= 0)
83             {
84                 canGo =
true;
85             }
86             
else
87             {
88                 PlayerPrefs.SetString(
"CounterRater", counter.ToString());
89             }
90
91         }
92         
else
93         {
94             PlayerPrefs.SetString(
"FirstTimeRater", "no");
95             PlayerPrefs.SetString(
"CounterRater", initialLaunchCount.ToString());
96         }
97
98         
return canGo;
99
100     }
101
102     
void showAPIRateFinal()
103     {
104         
try
105         {
106
107             
if (canShowRateIt())
108             {
109                 
if (checkNetworkAvailability())
110                 {
111                     rateAppShow();
112                 }
113
114             }
115         }
116         
catch (System.Exception)
117         {
118         }
119     }
120
121     
//Get Rater Box
122     GameObject raterObj;
123     
void showAPIRaterFinalX()
124     {
125         
//API Rater
126         raterObj = GameObject.Find(
"Canvas/Rater");
127         raterObj.SetActive(
false);
128         showAPIRateFinal();
129
130     }
131
132     
//Check internet availability
133     
bool checkNetworkAvailability()
134     {
135         
if (Application.internetReachability != NetworkReachability.NotReachable)
136         {
137             
return true;
138         }
139         
else
140         {
141             
return false;
142         }
143     }
144 }


Use this for initialization

Rater

Delete Counter Just for testing purpose make sure to comment this

PlayerPrefs.DeleteAll();

Create Rate URL

string appId = "com.ZeeMelApps.KittenRunner";GooglePlay, Amazon, Samsung

string appId = "49058ZeeMelApps.EndlessKittenRun_bc0tz99paqz1e";Windows 10

string appId = "1185855724";Apple

string rateURL = "market:details?id=" + appId;Google Play

string rateURL = "amzn:appsandroid?p=" + appId;Amazon

string rateURL = "samsungapps:ProductDetail" + appId;Samsung

string rateURL = "ms-windows-store:REVIEW?PFN=" + appId;Windows 10

string rateURL = "https:itunes.apple.comappid" + appId;Apple

Show Rater Dialog

Rate It

Open Rate URL

Hide Rate It

Remind Me Later

Hide Rate It

Get Rater Box

API Rater

Check internet availability



Gõ tìm kiếm nhanh...