public void CheckDeviceId() { Debug.Log("CheckDeviceId: Checking device id"); string deviceID = DeviceIDManager.GetDeviceID(); Debug.Log("CheckDeviceId: deviceID: " + deviceID); DatabaseReference dbDevices = FirebaseDatabase.DefaultInstance.GetReference(DevicesDbName); dbDevices.OrderByKey().EqualTo(deviceID).GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle error Debug.Log("CheckDeviceId db retrieval failed."); } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; if (snapshot.Value != null) { // Check deviceId db. Update game values to match that of db. var values = (Dictionary <string, object>)snapshot.Value; SetGameValuesFromDb((Dictionary <string, object>)values[deviceID], deviceID); } else { // If deviceID doesn't exist yet, then add deviceID to DB SetDbValuesFromGame(dbDevices.Child(deviceID)); } } }); }
// Use this for initialization void Start() { string password = DeviceIDManager.GetDeviceID(); if (!string.IsNullOrEmpty(password)) { deviceID.text = password; } }
// Use this for initialization void Start() { DeviceIDManager.deviceIDHandler += (string deviceid) => { if (!string.IsNullOrEmpty(deviceid)) { deviceID.text = deviceid; } }; DeviceIDManager.GetDeviceID(); }
public void InitializeDeviceId() { Debug.Log("InitializeDeviceId: Initializing device id"); string deviceID = DeviceIDManager.GetDeviceID(); Debug.Log("InitializeDeviceId: deviceID: " + deviceID); DatabaseReference dbDevices = FirebaseDatabase.DefaultInstance.GetReference(DevicesDbName); dbDevices.OrderByKey().EqualTo(deviceID).GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle error Debug.Log("InitializeDeviceId db retrieval failed."); // randomize features i guess startGameScript.SetRandomize(); SetDbValuesFromGame(dbDevices.Child(deviceID)); } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; if (snapshot.Value != null) { // check to see if deviceID exists in DB. // If it does, grab the userID and game version from the DB. var values = (Dictionary <string, object>)snapshot.Value; SetGameValuesFromDb((Dictionary <string, object>)values[deviceID], deviceID); } else { // If deviceID doesn't exist yet, randomize and initialize variables // and add deviceID to DB //startGameScript.SetRandomize(); SetDbValuesFromGame(dbDevices.Child(deviceID)); } } }); }