0630 firebase + google analytics

2021. 6. 30. 10:59Node.js

 

firebase에 처음 로그인하면 뜨는 유니티 세팅 완료 후

구글 클라우드 사용자 인증정보에서 웹 클라이언트 아이디 복사 후
Play 게임 클라이언트 ID에 넣고 저장, 사용 설정
클라이언트 ID에도 넣어서 빌드 한다.
googleIDToken 제대로 들어온다.

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;

public class App : MonoBehaviour
{
    public Text txtVersion;
    public Text txtId;
    public Text txtUsername;
    public Text txtState;
    public Image thumb;
    public Text txtAuthenticate;

    // Start is called before the first frame update
    void Start()
    {
        this.txtVersion.text = Application.version;


        Debug.Log("================================= init GPGS =================================");

        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()

            .EnableSavedGames()
            .RequestIdToken()
            .Build();

        PlayGamesPlatform.InitializeInstance(config);
        // recommended for debugging:
        PlayGamesPlatform.DebugLogEnabled = true;
        // Activate the Google Play Games platform
        PlayGamesPlatform.Activate();

        Debug.Log("================================= authenticate =================================");

        // authenticate user:
        PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptAlways, (result) => {
            Debug.Log("================================= result =================================" + result);
            Debug.Log("================================= local User =================================" + Social.localUser);
            Debug.Log("================================= autenciated =================================" + Social.localUser.authenticated);

            this.txtId.text = Social.localUser.id;
            this.txtUsername.text = Social.localUser.userName;
            this.txtState.text = Social.localUser.state.ToString();
            this.txtAuthenticate.text = result.ToString();

            if (result == SignInStatus.Success)
            {
                var localUser = (PlayGamesLocalUser)Social.localUser;
                var googleIdToken = localUser.GetIdToken();
                Debug.LogFormat("googleIdToken: {0}", googleIdToken);

                Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
                Firebase.Auth.Credential credential =
                Firebase.Auth.GoogleAuthProvider.GetCredential(googleIdToken, null);
                auth.SignInWithCredentialAsync(credential).ContinueWith(task => {
                    if (task.IsCanceled)
                    {
                        Debug.LogError("SignInWithCredentialAsync was canceled.");
                        return;
                    }
                    if (task.IsFaulted)
                    {
                        Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                        return;
                    }

                    Firebase.Auth.FirebaseUser newUser = task.Result;
                    Debug.LogFormat("User signed in successfully: {0} ({1})",
                        newUser.DisplayName, newUser.UserId);
                });
            }

            StartCoroutine(this.WaitforLoadThumb(() =>
            {
                Debug.Log(Social.localUser.image);
                Debug.LogFormat("{0}{1}", Social.localUser.image.width, Social.localUser.image.height);
                this.thumb.sprite = Sprite.Create(Social.localUser.image, new Rect(0, 0, Social.localUser.image.width, Social.localUser.image.height), Vector2.zero);
                this.thumb.SetNativeSize();
            }));
        });
    }
    private IEnumerator WaitforLoadThumb(System.Action callback)
    {
        while (true)
        {
            if (Social.localUser.image != null)
            {
                break;
            }
            yield return null;
        }
        callback();
    }
}

 

 


 

D:\Program Files\Nox\bin>adb connect 127.0.0.1:62001
unable to connect to 127.0.0.1:62001: cannot connect to 127.0.0.1:62001: 
대상 컴퓨터에서 연결을 거부했으므로 연결하지 못했습니다. (10061)

위의 오류가 뜰 경우

netstat -ano 입력시 

사용중인 포트 주소들이 쭉 뜬다.

netstat -ano | find "62001"

Kill a process with process id:

We can use below command to kill a process using process id(pid).

taskkill /PID  processId

출처:

https://www.windows-commandline.com/taskkill-kill-process/

 

TaskKill: Kill process from command line (CMD)

TaskKill: Kill process from command line (CMD) by Srini We can kill a process from GUI using Task manager. If you want to do the same from command line., then taskkill is the command you are looking for. This command has got options to kill a task/process

www.windows-commandline.com

뒤에다 62001의 PID ID를 적어서 프로세스 종료

 

다시 커넥트 하니 해결됐다.

 

'Node.js' 카테고리의 다른 글

유니티 연동 카카오 로그인  (0) 2021.07.08
0708 구글 애널리틱스  (0) 2021.07.08
Naver login  (0) 2021.06.24
GPGS Achievement  (0) 2021.06.23
0617 GPGS  (0) 2021.06.17