Friends List Display
Goal
Load the player’s friends list and iterate it to populate your UI.
Prerequisite
Make sure the player is authenticated first. Use use-case-1-auth-bootstrap.md for a safe startup flow.
Actions used
GameServicesLoadFriendsGameServicesGetLoadFriendsSuccessResult(on success; givesfriendsCount)GameServicesGetLoadFriendsError(on failure)GameServicesGetFriendInfo(iterate friends)
Variables
friendsCount(Int)friendIndex(Int)playerId(String),displayName(String),alias(String)
Flow
State:
LoadFriendsAction:
GameServicesLoadFriendsEvents:
successEvent→GetFriendsCountfailureEvent→GetLoadFriendsError(or show “no friends”)
State:
GetFriendsCountAction:
GameServicesGetLoadFriendsSuccessResult→friendsCountSet
friendIndex = 0
Loop:
While
friendIndex < friendsCount:Action:
GameServicesGetFriendInfo(input:friendIndex)Read outputs:
playerId,displayName,aliasAdd to UI
friendIndex++
Notes
Friend lists can be empty due to privacy settings or no friends on the service.
Refresh only when needed;
GameServicesLoadFriendsclears and repopulates the cached list.
Last updated
Was this helpful?