The PlayFab admin API Task wrapper wraps the Unity admin API to convert the async callback pattern to task async await pattern.
In most cases it would be preferrable to utilize the PlayFab C# SDK (Additional notes here) within Unity. This tool is most beneficial for projects that have already gone the Unity SDK route and are looking to gradually move code base to async await pattern.
Add the following line to your Unity package Packages/manifest.json
{
"dependencies": {
"com.breakstepstudios.playfab-admin-api-task-wrapper": "https://github.com/Breakstep-Studios/playfab-admin-api-task-wrapper.git#release",
}
}
/// <inheritdoc cref="PlayFabAdminAPI.GetTitleData"/>
public static Task<PlayFabCommonResponse<GetTitleDataResult>> GetTitleDataAsync(
GetTitleDataRequest request)
{
var taskCompletionSource = new TaskCompletionSource<PlayFabCommonResponse<GetTitleDataResult>>();
PlayFabAdminAPI.GetTitleData(request, (result) =>
{
taskCompletionSource.SetResult(new PlayFabCommonResponse<GetTitleDataResult>(result,null));
}, (error) =>
{
taskCompletionSource.SetResult(new PlayFabCommonResponse<GetTitleDataResult>(null, error));
});
return taskCompletionSource.Task;
}
public async PlayFabCommonResponse<GetTitleDataResult> GetTitleDataData()
{
var getTitleDataRequest = new GetTitleDataRequest
{
Keys = new List<string> { "Data" }
};
var result = await PlayFabAdminAPIWrapper.GetTitleDataAsync(getTitleDataRequest);
if (result.ContainsError)
{
return result;
}
}
- This package currently relies on playfab-admin-client-task-wrapper. This dependency is only due to the fact that
playfab-client-api-task-wrapper
defines some data models this repo relies/will rely on. In the long run it would more beneficial to pull those data models in to a seperate repo that both the client & admin api rely on. For example something likeplayfab-core-api-task-wrapper
.