googleanalytics / google-analytics-plugin-for-unity

Google Analytics plugin for the Unity game creation system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App Crash when i call Authenticate

sabriboughanmi opened this issue · comments

Hello Guys,

My app is crashing in when i call Social.localUser.Authenticate((bool success) ..
but when i comment these .RequestEmail() .RequestServerAuthCode(false) my app work correctly but i receive the Email of the user as Empty String.

Thanks for your Help in advance.

This is my Full Code:

`using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
using TMPro;

using UnityEngine;

public class GooglePlayLogin : MonoBehaviour {

public TextMeshProUGUI TextDebug,DebugEmail;


void Start () {
     PlayGamesConfig();


}


private void Update()
{
   //  Im testing in Update to get the Email
    if(DebugEmail.text == null || DebugEmail.text == "" )
    {
        GetUserInfo();
    }
    
}

private void PlayGamesConfig()
{

    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()

        .RequestEmail()
        .RequestServerAuthCode(false)
         
        .Build();
    

    PlayGamesPlatform.InitializeInstance(config);

   
    // recommended for debugging:
    PlayGamesPlatform.DebugLogEnabled = false;

    // Activate the Google Play Games platform
     PlayGamesPlatform.Activate();
}
public void GooglePlayGamesLogin()
{


        Social.localUser.Authenticate((bool success) =>
        {
            if (success)
            {
                TextDebug.text = success.ToString();
                GooglePlayGames.OurUtils.PlayGamesHelperObject.RunOnGameThread(
                       () => {
                           TextDebug.text += ((PlayGamesLocalUser)Social.localUser).Email ;
                           TextDebug.text += PlayGamesPlatform.Instance.GetServerAuthCode();
                       });


            }
            else
            {
                // handle success or failure
                TextDebug.text = success.ToString();
            }
        });

}

public void GetUserInfo()
{

    DebugEmail.text += ((PlayGamesLocalUser)Social.localUser).Email;
    DebugEmail.text += PlayGamesPlatform.Instance.GetUserEmail();

}


public void UserSignOut()
{
    PlayGamesPlatform.Instance.SignOut();
}

}`