question

Tim Koppers avatar image
Tim Koppers asked

Get player language with Azure Function

Hi,

I'm sending push notifications with Azure Functions, it all works as expected. But now I'm implementing a multi-language option. But for some reason I can't get the player's language in Azure Function?

Anybody to help?

CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

To retrieve the player’s language code, you can call the Entity API GetProfile. You can find the language code in the response’s Profile.Language field. For more information about this API, please read the API reference (https://docs.microsoft.com/rest/api/playfab/profiles/account-management/getprofile) of it.

Besides, you can also try to look for this field in the function's context. Typically, when a function is executed by players entities, the players' Entity Profiles would be passed to context parameters. Please refer to this documentation (https://docs.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript-af/cloudscript-af-context) for more details of Azure Functions' contexts.

If you have called the Entity Profiles in Azure Functions and encounter some problems when using it. Please provide more issue details, such as error messages, for our analysis.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Tim Koppers avatar image Tim Koppers commented ·

Thanks for the answer. I've found the solution indeed.

var profilesApi = new PlayFabProfilesInstanceAPI(apiSettings, authenticationContext);

PlayFabResult<GetEntityProfileResponse> profileResponse = await profilesApi.GetProfileAsync(entityProfileRequest);

if (profileResponse.Result.Profile.Language != String.Empty)
{
    playerLanguage = profileResponse.Result.Profile.Language;
    log.LogInformation($"Player profile language : {playerLanguage}");
}
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.