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:
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