Games that are distributed via the Treasure Launcher, do not need to authenticate users via the Treasure Connect flow.
The UE5 TDK will automatically detect if the user is using the Treasure Launcher and provides the developer with access to the user’s auth token.
static FString GetTDKAuthToken();
bool StartTDKSession(
TDK::LauncherModels::FStartSessionRequest Request,
const FStartSessionBatchDelegate& SuccessDelegate = FStartSessionBatchDelegate(),
const FTDKErrorDelegate& ErrorDelegate = FTDKErrorDelegate(),
);
struct TDKCPP_API FStartSessionRequest : public FTDKCppRequestCommon {
FString BackendWallet;
TArray<FString> ApprovedTargets;
int64 NativeTokenLimitPerTransaction;
int32 SessionDurationSec;
int32 SessionMinDurationLeftSec;
}
#include "TDKCommonUtils.h"
FString authToken = TDKCommon::TDKCommonUtils::GetTDKAuthToken();
#include "TDKCpp.h"
#include "Core/TDKError.h"
#include "Core/TDKLauncherDataModels.h"
#include "Core/TDKLauncherAPI.h"
TDKLauncherPtr LauncherPtr = ITDKCppModuleInterface::Get().GetLauncherAPI();
TDK::LauncherModels::FStartSessionRequest Request;
LauncherPtr->StartTDKSession(
Request,
TDK::UTDKLauncherAPI::FStartSessionBatchDelegate::CreateUObject(this, &ALauncherAPITest::OnSuccess),
TDK::FTDKErrorDelegate::CreateUObject(this, &ALauncherAPITest::OnError));
void ALauncherAPITest::OnSuccess(const TDK::LauncherModels::FStartSessionResponse& Result) const
{
UE_LOG(LogTemp, Warning, TEXT("Congratulations, you made your first successful Analytics API call!"));
UE_LOG(LogTemp, Warning, TEXT("Request Result: %s"), Result.Result ? TEXT("true") : TEXT("false"));
}
void ALauncherAPITest::OnError(const TDK::FTDKCppError& ErrorResult) const
{
UE_LOG(LogTemp, Error, TEXT("Something went wrong with your API call.\nHere's some debug information:\n%s"), *ErrorResult.GenerateErrorReport());
}