Users
API References for User Management Service
Explore the list of API functions available in Unity for managing users, including detailed descriptions and usage examples.
To use service functions, first ensure that the service is activated before. You can see services by opening "Service Hub" From the game's dashboard header.
Authentication
Login with email
This function will login a player with a pair of email and password, and return the token as result.
ServiceHub.Authentication.LoginWithEmail(LoginWithEmailParams input);
Register with email
This function will register a new user and then login him in and return the token.
ServiceHub.Authentication.RegisterWithEmail(RegisterWithEmailParams input);
Login with Google
With this function, you can log in user with Google Auth.
ServiceHub.Authentication.LoginWithGoogle(LoginWithGoogleParams input);
Login as guest
If you want to login users easily and don't show any form, guest login is for you! This function will login users with a unique id and mark the user as a guest. also, you can edit the user and add additional information in the future.
ServiceHub.Authentication.LoginAsGuest(LoginAsGuestParams input);
Login with token
When you login with any function, a token will return that will be used in requests to the server to identify the user. you should save this token in a safe place and load it on every game startup. to prevent login in every game session, you should call this function and pass the saved token.
ServiceHub.Authentication.LoginWithToken(LoginWithTokenParams input);
Check OTA is ready
Check if OTA is available and developer can use it. you can fall back to other login ways if it's not available.
ServiceHub.Authentication.IsOtaReady(new IsOtaReadyParams());
Send OTA token
If OTA is ready, this function will generate a random key and send it as SMS to specified phone number. this key is valid for few minutes to verify.
ServiceHub.Authentication.SendOtaToken(SendOtaTokenParams input);
Verify OTA token
After sending OTA key, you should get it by a form and verify it with this function. after that, login process will be done.
ServiceHub.Authentication.VerifyOtaToken(VerifyOtaTokenParams input);
Is logged in
This function return status of user athenticating.
ServiceHub.Authentication.IsLoggenIn();
Logout
This function closes all connections and forgets the user's token. then you can login another user.
ServiceHub.Authentication.Logout();
User Management
Find Users
This function helps you to find other users of the game, and then use their info in other functions.
ServiceHub.Services.Users.Find(new FindUserParams());
Get Current User's Info
This function return profile information of the current user
ServiceHub.Services.Users.GetCurrentUser()
Edit Current User Info
You can edit your current user profile with this function.
ServiceHub.Services.Users.EditUserById(new EditUserByIdParams())
Get User Info By Id
With this function, you can get the profile information of a specific user with his id
ServiceHub.Services.Users.FindUserById(new FindUserByIdParams())
Device Management
Get Users Devices
This function will return the active devices of the current user.
var devices = await ServiceHub.Services.Devices.FindMyDevices(new FindMyDeviceParams());
Revoke Device Access
This function removes access of a specific device and forces it log in again.
await ServiceHub.Services.Devices.RevokeDevice(new RevokeDeviceParams
{
DeviceId = 0
});
This function disables access to the revoked device and forces it to log in again.
Last updated