Skip to main content

ID Convert

1. Overview

Games may offer the ability to add platform friends or account provider friends. This makes it necessary to convert IDs between different systems.

After completing this tutorial, developers will know:

  • How to convert a set of open IDs from the account provider side to player Infos in PGOS.
  • How to convert a set of account IDs from the account platform side to player IDs in PGOS.

2. Keyword Definition

  • account open id: The User identity provided by the account-service provider.

  • account id: It is the account platform user ID owned by the player, not the account provider user ID. It is useful when the game integrates account providers that support multiple account platforms. It could be the SteamID of Steam, the XUID of XBox, etc. The maximum length is 64 characters.

    • The account id is set for the use of the BatchAccountIDToPlayerID API, which can convert the user id of the account platform to the player id of PGOS. In some scenarios, for example, in order to meet the compliance requirements of PSN/XBox, the block list of PSN/XBox must be synchronized to PGOS, at this time, the BatchAccountIDToPlayerID API will be very useful.

    • The account_id is also a field of the PlayerInfo structure, so other player clients can read it too.

3. Using the PlayerProfile Service

3.1 Open IDs To Platform Player Infos

Convert a set of open IDs from the account provider side to player Infos in PGOS.

Call BatchOpenIDToPlatformPlayerInfo from PlayerProfile module as follows:

  #include "PgosSDKCpp.h"

void SomeUObjectClass::SomeFunction()
{
auto PlayerProfile = IPgosSDKCpp::Get().GetClientPlayerProfileAPI();
if (PlayerProfile)
{
TArray<FString> AccountOpenIds;
AccountOpenIds.Add("1926974186468553003");
AccountOpenIds.Add("1926974186468586187");
PlayerProfile->BatchOpenIDToPlatformPlayerInfo(AccountOpenIds, [](const FPgosResult& Ret, const FClientPlatformPlayerInfoMap* Data) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("BatchOpenIDToPlatformPlayerInfo Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("BatchOpenIDToPlatformPlayerInfo Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}

3.2 Account IDs To Player IDs

Convert a set of account IDs from the account platform side to player IDs in PGOS. Call BatchAccountIDToPlayerID from PlayerProfile module as follows:

#include "PgosSDKCpp.h"

void SomeUObjectClass::SomeFunction()
{
auto PlayerProfile = IPgosSDKCpp::Get().GetClientPlayerProfileAPI();
if (PlayerProfile)
{
TArray<FString> AccountIds;
AccountIds.Add("2814657160907135");
AccountIds.Add("1345081161635083484");
PlayerProfile->BatchAccountIDToPlayerID(AccountIds, [](const FPgosResult& Ret, const FClientBatchAccountIDToPlayerIDResult* Data) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("BatchAccountIDToPlayerID Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("BatchAccountIDToPlayerID Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}