PICO Platform Unity SDK
ChallengesService Class Reference

Static Public Member Functions

static Task< ChallengeInvite (UInt64 challengeID, string[] userID)
 Invites specified user(s). More...
 
static Task< ChallengeGet (UInt64 challengeID)
 Gets the information for a specified challenge. More...
 
static Task< ChallengeEntryListGetEntries (UInt64 challengeID, LeaderboardFilterType filter, LeaderboardStartAt startAt, int pageIdx, int pageSize)
 Gets a list of challenge entries. More...
 
static Task< ChallengeEntryListGetEntriesAfterRank (UInt64 challengeID, ulong afterRank, int pageIdx, int pageSize)
 Gets a list of challenge entries after a specified rank. More...
 
static Task< ChallengeEntryListGetEntriesByIds (UInt64 challengeID, LeaderboardStartAt startAt, string[] userIDs, int pageIdx, int pageSize)
 Gets a list of challenge entries for specified users. More...
 
static Task< ChallengeListGetList (ChallengeOptions challengeOptions, int pageIdx, int pageSize)
 Gets a list of challenges. More...
 
static Task< ChallengeJoin (UInt64 challengeID)
 Lets the current user join a challenge. More...
 
static Task< ChallengeLeave (UInt64 challengeID)
 Lets the current user leave a challenge. More...
 
static Task LaunchInvitableUserFlow (UInt64 challengeID)
 Launches the invitation flow to let the current user invite friends to a specified challenge. This launches the system default invite UI where all of the user's friends are displayed. This is intended to be a shortcut for developers not wanting to build their own invite-friends UI. More...
 
static void SetChallengeInviteAcceptedOrLaunchAppNotificationCallback (Message< string >.Handler handler)
 Sets the callback to get notified when the user has accepted an invitation. More...
 

Detailed Description

Challenges create fun-to-join competitions among users, which can therefore provide users with more opportunities to interact with others. Challenges are asynchronous events, so users do not have to be online and do challenges at the same time.

Both you and your app's users are able to create challenges, configure challenge settings (including name, visibility, start time, and end time), and invite friends to join challenges to have fun together. Users can also join the challenges created by PICO.

Member Function Documentation

◆ Invite()

static Task< Challenge > Invite ( UInt64  challengeID,
string[]  userID 
)
inlinestatic

Invites specified user(s).

Parameters
challengeIDThe ID of the challenge to which user(s) are invited.
userIDThe ID(s) of the user(s) to invite.
Returns
Returns the Challenge struct that contains the information about the challenge, such as challenge ID, the leaderboard the challenge belongs to, the challenge's end date and start date, etc.

◆ Get()

static Task< Challenge > Get ( UInt64  challengeID)
inlinestatic

Gets the information for a specified challenge.

Parameters
challengeIDThe ID of the challenge to get information for.
Returns
Returns the Challenge struct that contains the information about the challenge, such as challenge ID, the leaderboard the challenge belongs to, the challenge's end date and start date, etc.

◆ GetEntries()

static Task< ChallengeEntryList > GetEntries ( UInt64  challengeID,
LeaderboardFilterType  filter,
LeaderboardStartAt  startAt,
int  pageIdx,
int  pageSize 
)
inlinestatic

Gets a list of challenge entries.

Parameters
challengeIDThe ID of the challenge whose entries are to be returned.
filterRestricts the scope of entries to return:
  • 0: None (returns all entries of the specified leaderboard)
  • 1: Friends (returns the entries of the friends of the current logged-in user)
  • 2: Unknown (returns no entry)
  • 3: UserIds (returns the entries of specified users)
startAtDefines where to start returning challenge entries, the enumerations are:
  • 0: Top (return entries from top 1)
  • 1: CenteredOnViewer (place the current logged-in user's entry in the middle of the list on the first page. For example, if the total number of entries is 10, pageSize is set to 5, and the user's rank is top 5, the ranks displayed on the first page will be top 3, 4, 5, 6, and 7. Top 1 and 2 will not be displayed, and top 8, 9, and 10 will be displayed on the second page)
  • 2: CenteredOnViewerOrTop (place the current logged-in user's entry on the top of the list on the first page. For example, if the total number of entries is 10, pageSize is set to 5, and the user's rank is top 5, the ranks displayed on the first page will be top 5, 6, 7, 8, and 9. Top 1, 2, 3, and 4 will not be displayed, and top 10 will be displayed on the second page)
  • 3: Unknown (returns an empty list)
pageIdxDefines which page of entries to return. The first page index is 0. For example, if you want to get the first page of entries, pass 0; if you want to get the second page of entries, pass 1.
pageSizeDefines the number of entries to return on the page.
Returns
Returns a list of matching entries.

◆ GetEntriesAfterRank()

static Task< ChallengeEntryList > GetEntriesAfterRank ( UInt64  challengeID,
ulong  afterRank,
int  pageIdx,
int  pageSize 
)
inlinestatic

Gets a list of challenge entries after a specified rank.

Parameters
challengeIDThe ID of the challenge whose entries are to be returned.
afterRankDefines the rank after which the entries are to be returned.
pageIdxDefines which page of entries to return. The first page index is 0. For example, if you want to get the first page of entries, pass 0; if you want to get the second page of entries, pass 1.
pageSizeDefines the number of entries to return on each page.
Returns
Returns a list of matching entries.

◆ GetEntriesByIds()

static Task< ChallengeEntryList > GetEntriesByIds ( UInt64  challengeID,
LeaderboardStartAt  startAt,
string[]  userIDs,
int  pageIdx,
int  pageSize 
)
inlinestatic

Gets a list of challenge entries for specified users.

Parameters
challengeIDThe ID of the challenge whose entries are to be returned.
startAtDefines where to start returning challenge entries, the enumerations are:
  • 0: Top (return entries from top 1)
  • 1: CenteredOnViewer (place the current logged-in user's entry in the middle of the list on the first page. For example, if the total number of entries is 10, pageSize is set to 5, and the user's rank is top 5, the ranks displayed on the first page will be top 3, 4, 5, 6, and 7. Top 1 and 2 will not be displayed, and top 8, 9, and 10 will be displayed on the second page)
  • 2: CenteredOnViewerOrTop (place the current logged-in user's entry on the top of the list on the first page. For example, if the total number of entries is 10, pageSize is set to 5, and the user's rank is top 5, the ranks displayed on the first page will be top 5, 6, 7, 8, and 9. Top 1, 2, 3, and 4 will not be displayed, and top 10 will be displayed on the second page)
  • 3: Unknown (returns an empty list)
userIDsDefines a list of user IDs to get entries for.
pageIdxDefines which page of entries to return. The first page index is 0. For example, if you want to get the first page of entries, pass 0; if you want to get the second page of entries, pass 1.
pageSizeDefines the number of entries to return on each page.
Returns
Returns a list of matching entries.

◆ GetList()

static Task< ChallengeList > GetList ( ChallengeOptions  challengeOptions,
int  pageIdx,
int  pageSize 
)
inlinestatic

Gets a list of challenges.

Parameters
challengeOptionsRestricts the scope of challenges to return. You can define the start date and end date of challenges, the leaderboard the challenges belong to, etc.
pageIdxDefines which page of challenges to return. The first page index is 0. For example, if you want to get the first page of entries, pass 0; if you want to get the second page of entries, pass 1.
pageSizeDefines the number of challenges to return on each page.
Returns
Returns a list of matching challenges.

◆ Join()

static Task< Challenge > Join ( UInt64  challengeID)
inlinestatic

Lets the current user join a challenge.

Parameters
challengeIDThe ID of the challenge to join.
Returns
Returns the Challenge struct that contains the information about the challenge, such as challenge ID, the leaderboard the challenge belongs to, the challenge's end date and start date, etc.

◆ Leave()

static Task< Challenge > Leave ( UInt64  challengeID)
inlinestatic

Lets the current user leave a challenge.

Parameters
challengeIDThe ID of the challenge to leave.
Returns
Returns the Challenge struct that contains the information about the challenge, such as challenge ID, the leaderboard the challenge belongs to, the challenge's end date and start date, etc.

◆ LaunchInvitableUserFlow()

static Task LaunchInvitableUserFlow ( UInt64  challengeID)
inlinestatic

Launches the invitation flow to let the current user invite friends to a specified challenge. This launches the system default invite UI where all of the user's friends are displayed. This is intended to be a shortcut for developers not wanting to build their own invite-friends UI.

Parameters
challengeIDThe ID of the challenge.

◆ SetChallengeInviteAcceptedOrLaunchAppNotificationCallback()

static void SetChallengeInviteAcceptedOrLaunchAppNotificationCallback ( Message< string >.Handler  handler)
inlinestatic

Sets the callback to get notified when the user has accepted an invitation.

Note
You can get the ChallengeID by 'Message.Data'.
Parameters
handlerThe callback function will be called when receiving the Notification_Challenge_LaunchByInvite message.