|
@@ -19,6 +19,7 @@ public class User
|
|
|
public string usermail = string.Empty;
|
|
|
public string gender = string.Empty;
|
|
|
public string ageRange = string.Empty;
|
|
|
+ public string device = string.Empty;
|
|
|
public User()
|
|
|
{
|
|
|
//Required for JSON serialization and deserialization
|
|
@@ -26,7 +27,7 @@ public class User
|
|
|
|
|
|
public override string ToString()
|
|
|
{
|
|
|
- return string.Format("{0}, {1}, {2}, {3}", id, name, surname, username, usermail, gender, ageRange);
|
|
|
+ return string.Format("{0}, {1}, {2}, {3}, {4}", id, name, surname, username, usermail, device, gender, ageRange);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -232,14 +233,27 @@ public class GameDatabaseManager : MonoBehaviour
|
|
|
|
|
|
_instance = this;
|
|
|
DontDestroyOnLoad(gameObject);
|
|
|
+ CheckDeviceID(SystemInfo.deviceUniqueIdentifier, OnCheckDevice);
|
|
|
}
|
|
|
-
|
|
|
- public void RegisterUser(string userId, string name, string surname, string username, string usermail,Action<bool, string> onComplete)
|
|
|
+
|
|
|
+ private void OnCheckDevice(bool arg1, User arg2)
|
|
|
+ {
|
|
|
+ SocialManager.Instance.userID = arg2.id;
|
|
|
+ if(!string.IsNullOrEmpty(SocialManager.Instance.userID))
|
|
|
+ {
|
|
|
+ Debug.LogError(arg2.ToString());
|
|
|
+ PlayerPrefs.SetInt("APPLE", 1);
|
|
|
+ PlayerPrefs.Save();
|
|
|
+ }
|
|
|
+ Debug.LogError(arg2.ToString());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void RegisterUser(string userId, string name, string surname, string username, string usermail, string deviceId, Action<bool, string> onComplete)
|
|
|
{
|
|
|
- StartCoroutine(RegisterUserCoroutine(userId, name, surname, username, usermail, onComplete));
|
|
|
+ StartCoroutine(RegisterUserCoroutine(userId, name, surname, username, usermail, deviceId, onComplete));
|
|
|
}
|
|
|
|
|
|
- private IEnumerator RegisterUserCoroutine(string userId, string name, string surname, string username, string usermail, Action<bool, string> onComplete)
|
|
|
+ private IEnumerator RegisterUserCoroutine(string userId, string name, string surname, string username, string usermail, string deviceId, Action<bool, string> onComplete)
|
|
|
{
|
|
|
string registerUserUrl = URL + "RegisterUser.php";
|
|
|
|
|
@@ -249,9 +263,10 @@ public class GameDatabaseManager : MonoBehaviour
|
|
|
form.AddField("surname", surname);
|
|
|
form.AddField("username", username);
|
|
|
form.AddField("usermail", usermail);
|
|
|
+ form.AddField("deviceID", deviceId);
|
|
|
//form.AddField("userage", gender);
|
|
|
//form.AddField("usergender", ageRange);
|
|
|
- form.AddField("hash", ComputeHash(userId + name + surname + username+ usermail + GameConstants.SECRET_KEY));
|
|
|
+ form.AddField("hash", ComputeHash(userId + name + surname + username+ usermail + deviceId + GameConstants.SECRET_KEY));
|
|
|
|
|
|
WWW w = new WWW(registerUserUrl, form);
|
|
|
yield return w;
|
|
@@ -276,7 +291,42 @@ public class GameDatabaseManager : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ public void CheckDeviceID(string deviceID, Action<bool, User> onComplete)
|
|
|
+ {
|
|
|
+ StartCoroutine(CheckDeviceCoroutine(deviceID, onComplete));
|
|
|
+ }
|
|
|
+
|
|
|
+ private IEnumerator CheckDeviceCoroutine(string deviceID, Action<bool, User> onComplete)
|
|
|
+ {
|
|
|
+ string loadDeviceUrl = URL + "RequestCheckDeviceID.php";
|
|
|
+
|
|
|
+ WWWForm form = new WWWForm();
|
|
|
+ form.AddField("userDeviceId", deviceID);
|
|
|
+
|
|
|
+ WWW w = new WWW(loadDeviceUrl, form);
|
|
|
+ yield return w;
|
|
|
+
|
|
|
+ Debug.Log(w.text);
|
|
|
+
|
|
|
+ if (w.error != null)
|
|
|
+ {
|
|
|
+ AVDebug.LogError(w.error);
|
|
|
+ onComplete(false, null);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ User user = JsonReader.Deserialize<User>(w.text);
|
|
|
+ onComplete(true, user);
|
|
|
+ }
|
|
|
+ catch (JsonDeserializationException ex)
|
|
|
+ {
|
|
|
+ AVDebug.LogError(ex.Message);
|
|
|
+ onComplete(false, null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
public void LoadUser(string userId, Action<bool, User> onComplete)
|
|
|
{
|
|
|
StartCoroutine(LoadUserCoroutine(userId, onComplete));
|