Sign In Register

How can we help you today?

Start a new topic

Device authentication with custom Id

 Hello Folks,


I am trying to perform a DeviceAuthentication using a custom device ID in Unity context. The documentation says, that there is a "SetDeviceId(String id)" method in this kind of authentication. Unfortunately, My IDE claims that this is not true.

I am talking about this documentation topic: https://api.gamesparks.net/?_ga=1.233185688.702267973.1493143088#deviceauthenticationrequest


Do you guys know why? Let me kindly ask you not to put in question why I do this and so on. I would really appreciate it : - )


Kind Regards


If you are using chaining, here is a modified version of Alberto's code :


 

using System.Collections;
using System.Collections.Generic;
using GameSparks.Api.Requests;

public class ExtendedDeviceAuthentication : DeviceAuthenticationRequest {

	public ExtendedDeviceAuthentication SetId(string id)
     {
		Dictionary<string, object> req = (Dictionary<string, object>)JSONData;
		req.Remove ("deviceId");
		req.Add ("deviceId", id);
        return this;
	}
}

 

Alright. For all those trying to do this, simply extend the DeviceAuthentication class and add a method to override the id. Following code should make the trick



 

using System.Collections;
using System.Collections.Generic;
using GameSparks.Api.Requests;

public class ExtendedDeviceAuthentication : DeviceAuthenticationRequest {

	public void SetId(string id){
		Dictionary<string, object> req = (Dictionary<string, object>)JSONData;
		req.Remove ("deviceId");
		req.Add ("deviceId", id);
	}
}

 


2 people like this

Hi Alberto


Set Device Id is available on some SDK's that is why it is included in the documentation .

In the Unity SDK gamesparks gets the device id straight from Unity when it runs.


Regards

Katie 

Login to post a comment