User
Retrieve user data
Before requesting user data from the GameAPI you must check if the service is available. The service not being available will not cause errors to be thrown but no data is available so it will not be returned to the game.
Once you’ve made the check, you are able to retrieve user data from the GameAPI.User.getUser method. When the user is logged in the user’s data is retrieved and when he is not, guest data is retrieved.
The returned data has the following format:
Register User:
{
age: 31
birthday:
{
day: 1
month: 2
year: 1984
}
displayName: "-spore"
gender: "m"
guid: "288515379907594968"
level: "user"
locale: "en-EN"
pic_square: "http://static.spilcdn.com/fa/gm/pb/2/preview/5754509"
pic_square_large: "http://static.spilcdn.com/fa/gm/pb/2/rendering/5754509"
uid: ""
};
Guest User:
{
age: ""
birthday: ""
displayName: "guest"
gender: "u"
guid: "288512820609747052"
level: "guest"
locale: "en-EN"
pic_square: "http://static.spilcdn.com/fa/img/userprofile/dummy_small.gif"
pic_square_large: "http://static.spilcdn.com/fa/img/userprofile/dummy_big.gif"
uid: ""
};
What about guest users?
It’s up to you if you want to allow guest users to play your game or not. In case you allow only register users to play then you should create a landing screen for the guest users. In this screen you explain that they need to register in order to play and place a button that triggers our login pop up.
That the login pop up will only display if the user is not logged in yet. If the game is running outside of Spil Portal environment the method behaves as an empty function.
Next step: Friends