Share via


XblAchievementsManagerAddLocalUser

Initialize the Achievements Manager and generate a local cache of achievements for a user.

Syntax

HRESULT XblAchievementsManagerAddLocalUser(  
         XblUserHandle user,  
         XTaskQueueHandle queue  
)  

Parameters

user   _In_
Type: XblUserHandle

Xbox Live User to fetch achievements for.

queue   _In_opt_
Type: XTaskQueueHandle

Queue to be used for background operation for this user (Optional).

Return value

Type: HRESULT

HRESULT return code for this API operation.

Remarks

Because XblAchievementsManagerAddLocalUser requires an internet connection to correctly track user info, it should only be called while connected to the internet. Using XNetworkingRegisterConnectivityHintChanged is a good way to check for a connection.

If the Achievements Manager is not initialized, calls to XblAchievementsManagerUpdateAchievement will fail. In this case, calls to XblAchievementsUpdateAchievementAsync should be made instead as achievement conditions are met to ensure that progression is still tracked. Here is an example of how this can be implemented:

HRESULT hr = XblAchievementsManagerUpdateAchievement(xuid, "2", 3);
if (FAILED(hr))
{
    XAsyncBlock async{};
    hr = XblAchievementsUpdateAchievementAsync(m_xblContext, xuid, "2", 3, &async);
    if (SUCCEEDED(hr))
    {
        // this simple example is thread blocking. 
        // replace with whatever async pattern used by other XAsync calls in title
        XAsyncGetStatus(&async, true); 
    }
}

Requirements

Header: achievements_manager_c.h

Library: Microsoft.Xbox.Services.14x.GDK.C.lib

See also

achievements_manager_c