Checking Age
If an age gate was required, an API call to /age-gate/check
now must be made to determine the next step in the workflow. If the player’s age is below the minimum age for the game configured in the Publisher Portal, the returned status
field will be PROHIBITED
. At this point, the player should be blocked from continuing in the game. If the player gave a date of birth that requires verifiable parental consent in the current location, then the status
field will have the value CHALLENGE
and an ID to a new Consent Challenge will be returned in a field called challengeID
. The game must then ask the player to seek parental consent. Finally, if the status
value is PASS
, then the player can continue into the game.
Creating a Session with Unreal C++
void UKidWorkflow::StartKidSessionWithDOB(const FString& Location, const FString& DOB)
{
TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
JsonObject->SetStringField(TEXT("dateOfBirth"), DOB);
JsonObject->SetStringField(TEXT("jurisdiction"), Location);
FString ContentJsonString;
TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&ContentJsonString);
FJsonSerializer::Serialize(JsonObject.ToSharedRef(), Writer);
HttpRequestHelper::PostRequestWithAuth(BaseUrl + TEXT("/age-gate/check"), ContentJsonString,
AuthToken, [this](FHttpResponsePtr Response, bool bWasSuccessful)
{
if (bWasSuccessful)
{
TSharedPtr<FJsonObject> JsonResponse;
TSharedRef<TJsonReader<>> Reader =
TJsonReaderFactory<>::Create(Response->GetContentAsString());
if (FJsonSerializer::Deserialize(Reader, JsonResponse))
{
FString Status = JsonResponse->GetStringField(TEXT("status"));
if (Status == TEXT("CHALLENGE"))
{
TSharedPtr<FJsonObject> Challenge =
JsonResponse->GetObjectField(TEXT("challenge"));
FString ChallengeId =
Challenge->GetStringField(TEXT("challengeId"));
FString OneTimePassword =
Challenge->GetStringField(TEXT("oneTimePassword"));
FString QRCodeUrl =
Challenge->GetStringField(TEXT("url"));
SaveChallengeId(ChallengeId);
ShowConsentChallenge(ChallengeId, ConsentTimeoutSeconds, OneTimePassword,
QRCodeUrl, [this](bool bConsentGranted, const FString &SessionId)
{
if (bConsentGranted)
{
GetSessionPermissions(SessionId, TEXT(""));
ClearChallengeId();
}
else
{
HandleNoConsent();
}
});
}
else if (Status == TEXT("PASS"))
{
SessionInfo = JsonResponse->GetObjectField(TEXT("session"));
SaveSessionInfo();
}
else if (Status == TEXT("PROHIBITED"))
{
HandleProhibitedStatus();
}
}
}
});
}