Sign In Register

How can we help you today?

Start a new topic
Answered

GameSparksAvailable Doesnt Invoke

Hi,

I try to use GameSparksAvailable but that event never triggered when GS is available or not.


I dont know if im using correctly.

 

void Start()
    {
        GameSparksApi.GameSparksAvailable += HandleGameSparksAvailable;
    }


    public void HandleGameSparksAvailable(object sender, GameSparks.GameSparksAvailabilityEventArgs e)
    {
        Debug.Log("GS:HandleGameSparksAvailable: ");

        if (e.available)
        {
            //what is meaning of the bool parameter ???
            new DeviceAuthenticationRequest()
                    .Send((response) =>
            {
                if (response.HasErrors)
                {
                } else
                {
                    UserManager.Instance.UpdateInformation(false);

                }
            });
        }
    }

 


Thank


Best Answer
Hey Luis,

So you want to authenticate the user as soon as gamesparks comes available? Is that right?
You actually dont need to send availability event into the delegate, as it is happy to accept a bool, as in the code below...

 

void Start()
{
	GS.GameSparksAvailable += HandleGameSparksAvailable;
}

void HandleGameSparksAvailable (bool isAvailable)
{
	if(isAvailable)
	{
		Debug.Log("GAMESPARKS AVAILABLE...");
		new GameSparks.Api.Requests.DeviceAuthenticationRequest ()
			.SetDurable (true)
				.Send ((response) => {
						
				if(!response.HasErrors)
				{
					Debug.Log("Device Authenticated with ID => "+response.UserId);
				}
			});
	}
	else
	{
		Debug.Log("GAMESPARKS NOT AVAILABLE...");
	}
}

 

That should work for you.
If you are still having problems you should check your Gamesparks SDK settings in unity and maybe run the test-scene to see if you get the GS Available  message there.


Hope that helps,
- Sean

1 Comment

Answer
Hey Luis,

So you want to authenticate the user as soon as gamesparks comes available? Is that right?
You actually dont need to send availability event into the delegate, as it is happy to accept a bool, as in the code below...

 

void Start()
{
	GS.GameSparksAvailable += HandleGameSparksAvailable;
}

void HandleGameSparksAvailable (bool isAvailable)
{
	if(isAvailable)
	{
		Debug.Log("GAMESPARKS AVAILABLE...");
		new GameSparks.Api.Requests.DeviceAuthenticationRequest ()
			.SetDurable (true)
				.Send ((response) => {
						
				if(!response.HasErrors)
				{
					Debug.Log("Device Authenticated with ID => "+response.UserId);
				}
			});
	}
	else
	{
		Debug.Log("GAMESPARKS NOT AVAILABLE...");
	}
}

 

That should work for you.
If you are still having problems you should check your Gamesparks SDK settings in unity and maybe run the test-scene to see if you get the GS Available  message there.


Hope that helps,
- Sean