// writing guest player to the database private IEnumerator writePlayer(Firebase.Auth.IUserInfo userInfo) { string userId = userInfo.UserId; //tempory workaround string playername = userNameText.text; string email = userInfo.Email; // set defult image for guest string photo_url = WWW.UnEscapeURL("https://firebasestorage.googleapis.com/v0/b/softchasers-catch-me.appspot.com/o/avata.png?alt=media&token=33f08ed1-3154-49f8-892d-dfb1da8ccdce"); DebugLog(String.Format("Wirting Player at Register User Id '{0}':", userId)); DebugLog(String.Format("playername Providers for '{0}':", playername)); DebugLog(String.Format("Email Providers for '{0}':", email)); // create object Player player = new Player(playername, email, userId, photo_url); // save username and photo to internal unity runtime storage to show in menu PlayerPrefs.SetString("urlinfo", photo_url.ToString()); PlayerPrefs.SetString("username", playername); string json = JsonUtility.ToJson(player); Debug.Log("original json"); Debug.Log(json); json = json.Substring(0, json.Length - 1); Debug.Log("cutted"); Debug.Log(json); //approch to save current time stamp in firebase for unity string timestampAdd = @" , ""createdtimestamp"": {"".sv"" : ""timestamp""} } "; Debug.Log("adder"); Debug.Log(timestampAdd); json = json + timestampAdd; Debug.Log("added"); Debug.Log(json); // create a root datbase instance and map it to public refernace playerDbRef = FirebaseDatabase.DefaultInstance.RootReference; DebugLog(String.Format("playerDbRef {0}...", playerDbRef)); //save the values under child player and user id generated by firebase auth playerDbRef.Child("players").Child(userId).SetRawJsonValueAsync(json); yield return(null); }
// Display user information. void DisplayUserInfo(Firebase.Auth.IUserInfo userInfo, int indentLevel) { string indent = new String(' ', indentLevel * 2); var userProperties = new Dictionary <string, string> { { "Display Name", userInfo.DisplayName }, { "Email", userInfo.Email }, { "Photo URL", userInfo.PhotoUrl != null?userInfo.PhotoUrl.ToString() : null }, { "Provider ID", userInfo.ProviderId }, { "User ID", userInfo.UserId } }; foreach (var property in userProperties) { if (!String.IsNullOrEmpty(property.Value)) { Debug.Log(String.Format("{0}{1}: {2}", indent, property.Key, property.Value)); } } }