I’m trying to register a callback for when the login process complete using the OnlineIdentity interface. It seems the AddOnLoginCompleteDelegate_Handle function should do the job.
However, the documentation barely explains anything, an approach that unfortunately is very common in UE4:
I mean, how do I call it? A one line example or explanation seems very basic, but the documentation has nothing.
Using Google, I almost found a way to do that:
IOnlineIdentityPtr IdentityInterface = IOnlineSubsystem::Get()->GetIdentityInterface();
IdentityInterface->AddOnLoginCompleteDelegate_Handle(0, FOnLoginCompleteDelegate::CreateUObject(this, &ALeaderboardsManager::OnLogin));
But I think this approach doesn’t work with UE 4.27 anymore, since CreateUObject seems to not exist (a build error is raised). Anyway, any help would be appreciated.
Glad you are having the same problem!
I have been going crazy this week, thinking in was my programming
The below compiles but never calls
const IOnlineIdentityPtr IdentityInterface = IOnlineSubsystem::Get()->GetIdentityInterface();
this->OnLoginDelegateHandle = IdentityInterface->AddOnLoginCompleteDelegate_Handle(0, FOnLoginComplete::FDelegate::CreateUObject(this, &USTGameInstance::OnLoginCompleteCallback));
Any known fixes?
It appears that my callback function was not declared correctly. It is building now. I declare it like this:
void OnLogin(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error);
And then I registered it as a callback:
IdentityInterface->AddOnLoginCompleteDelegate_Handle(0, FOnLoginComplete::FDelegate::CreateUObject(this, &ALeaderboardsManager::OnLogin));
It is building now and the callback is being called. SkinnyBruv, did you tried to debug to be sure it was reaching the point where the callback should be called? Your code seems very similar to mine now.
It was reaching the point of callback.
In one of the UE4.26 builds, callbacks were bugged.