Android
This article guides you through setting up VK as an identity provider, enabling your Android game to access Player Network authentication services.
Prerequisites
1. Set up the VK App in VK Developer Dashboard
- Create an account for Player Network Console.
- Create a new project for your game, or join an existing one.
- Download the SDK.
- Integrate the SDK.
- Add VK as an authentication method for your project on Player Network Console.
Step 1: Configure the SDK for VK login
In the
AndroidManifest
file, make sure the required permissions have been added. VK requires access to the network.<uses-permission android:name="android.permission.INTERNET"/>
In the
vk_integers.xml
file underAssets/Plugins/Android/INTLVK.androidlib/res/values
, add the following configurations.<integer name="com_vk_sdk_AppId">your_app_id</integer>
Replace
your_app_id
with the registered VK App ID.Open the project's INTLConfig.ini:
[Android LifeCycle]
LIFECYCLE = VK
[VK]
VK_APP_ID = {INTL_VK_APP_ID}- Add VK to
LIFECYCLE
. For more information, see SDK environment. - Replace
{INTL_VK_APP_ID}
with the registered VK App ID.
- Add VK to
Step 2: Add VK login
Add an observer to handle authentication callbacks.
- Unity
- Unreal Engine
// Add callbacks
public void AddAuthObserver()
{
INTLAPI.AddAuthResultObserver(OnAuthResultEvent);
}
// Remove callbacks
public void RemoveAuthObserver()
{
INTLAPI.RemoveAuthResultObserver(OnAuthResultEvent);
}
// Process the INTLAuthResult callback
public void OnAuthResultEvent(INTLAuthResult ret)
{
Debug.Log($"MethodID: {ret.MethodId}");
string methodTag = "";
if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_LOGIN)
{
methodTag = "Login";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_BIND)
{
methodTag = "Bind";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_AUTOLOGIN)
{
methodTag = "AutoLogin";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_QUERY_USER_INFO)
{
methodTag = "QueryUserInfo";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_GET_AUTH_RESULT)
{
methodTag = "GetAuthResult";
}
}C++ Event Handling (above v1.15)
//configure callback
FINTLAuthEvent authEvent;
authEvent.AddUObject(this, &OnAuthResult_Implementation);
UINTLSDKAPI::SetAuthResultObserver(authEvent);
// Remove callbacks
UINTLSDKAPI::GetAuthResultObserver().Clear();void OnAuthResult_Implementation(FINTLAuthResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}Unreal Event Handling
void OnAuthResult_Implementation(FINTLAuthResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}Call the
AutoLogin
method.- Unity
- Unreal Engine
INTLAPI.AutoLogin();
UINTLSDKAPI::AutoLogin();
Call the
Login
method to ask for user input if auto-login fails.- Unity
- Unreal Engine
INTLAPI.Login(INTLChannel.VK);
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelVK);
Sync client authentication state with the game's backend and wait for the final authentication result.
Step 3: Test the login function
Search for the keyword "AuthResult" in the Player Network SDK logs to verify if the correct channel name and OpenID are returned. If they are, it indicates a successful configuration and the login function has been added successfully.