Getting google play nickname and user id

Hey guys, I’m trying to get google play nickname and userID, after loggin game to google play services but I’m getting same ID with different user logged in and PlayerName is returning zero all the time. I’ve tried BP and I’ve also tried some cpp function but still with no luck:

return PlayerController->PlayerState->UniqueId->GetHexEncodedString();
return PlayerController->PlayerState->GetPlayerName();

Controller is one from the Show external Login UI BP which is used to get player logged in:

2020-06-01 16_29_56-BPGameInstance.png

Do you have any idea how to make it work? Thanks!

I subscribe to the question.

Use cpp function for the nickname.
I’m not sure this is the right way for that.

  • In your Project.Build.cs:

PrivateDependencyModuleNames.Add(“OnlineSubsystem”);

  • In your cpp file:

#include “Online.h”

  • In function that return FString:

auto Identity = Online::GetIdentityInterface();
if (Identity.IsValid())
{
return Identity->GetPlayerNickname(0);
}
return FString();