Search Unity

Google Play Services Sign In Issue

Discussion in 'Multiplayer' started by Tarik1989, Feb 16, 2020.

  1. Tarik1989

    Tarik1989

    Joined:
    Oct 6, 2019
    Posts:
    4
    Hi,

    I was wondering if anyone could help me on this problem I'm having. I've written a script for to allow me to sign in to google play services and also check the leaderboards. However when I go to sign in using my internal closed build Google Play pops up, the loading sign and then nothing happens. I've done a bit of research on forums and tried using both my upload certificate and app signing key over on google cloud platform however neither work. Would anyone be able to advise if it's my code below or any other suggestions? Thanks so much!
    Code (CSharp):
    1. using UnityEngine;
    2. using GooglePlayGames;
    3. using UnityEngine.SceneManagement;
    4.  
    5. public class LeaderboardsController : MonoBehaviour
    6. {
    7.     public static LeaderboardsController instance;
    8.  
    9.     private const string LEADERBOARDS_SCORE = "CgpI5fOtyc7fEAIQaA";
    10.  
    11.     private void Awake()
    12.     {
    13.         MakeSingleton();
    14.     }
    15.  
    16.  
    17.     void Start()
    18.     {
    19.  
    20.         PlayGamesPlatform.Activate();
    21.  
    22.  
    23.     }
    24.  
    25.     private void OnEnable()
    26.     {
    27.  
    28.         SceneManager.sceneLoaded += LevelWasLoaded;
    29.     }
    30.  
    31.  
    32.     private void OnDisable()
    33.     {
    34.         SceneManager.sceneLoaded -= LevelWasLoaded;
    35.     }
    36.  
    37.  
    38.     private void LevelWasLoaded(Scene scene, LoadSceneMode mode)
    39.     {
    40.         if (SceneManager.GetSceneByName(PlayerPrefsScript.GetSelectedScene()).isLoaded)
    41.         {
    42.  
    43.             ReportScore(PlayerPrefsScript.GetMediumScore());
    44.  
    45.  
    46.         }
    47.  
    48.     }
    49.  
    50.     void MakeSingleton()
    51.     {
    52.  
    53.         if(instance == null)
    54.         {
    55.  
    56.             instance = this;
    57.             DontDestroyOnLoad(gameObject);
    58.  
    59.         }
    60.  
    61.         else
    62.         {
    63.             Destroy(gameObject);
    64.         }
    65.  
    66.  
    67.  
    68.  
    69.     }
    70.  
    71.     public void ConnectOrDisconnectOnGooglePlayGames()
    72.     {
    73.  
    74.         if (Social.localUser.authenticated)
    75.         {
    76.             PlayGamesPlatform.Instance.SignOut();
    77.  
    78.         }
    79.  
    80.         else
    81.         {
    82.  
    83.             Social.localUser.Authenticate((bool success) =>
    84.             {
    85.  
    86.             });
    87.  
    88.         }
    89.  
    90.     }
    91.  
    92.  
    93.     public void OpenLeaderboardsScore()
    94.     {
    95.         if (Social.localUser.authenticated)
    96.         {
    97.  
    98.             PlayGamesPlatform.Instance.ShowLeaderboardUI(LEADERBOARDS_SCORE);
    99.  
    100.         }
    101.  
    102.  
    103.  
    104.     }
    105.  
    106.     void ReportScore(int score)
    107.     {
    108.         if (Social.localUser.authenticated)
    109.         {
    110.  
    111.             Social.ReportScore(score, LEADERBOARDS_SCORE, (bool success) =>
    112.             {
    113.  
    114.             });
    115.  
    116.         }
    117.  
    118.     }
    119.  
    120.  
    121. }