PICO Platform Unity SDK
UserService Class Reference

Static Public Member Functions

static Task< string > GetAccessToken ()
 Returns an access token for this user. More...
 
static Task< UserGetLoggedInUser ()
 Gets the information about the current logged-in user. More...
 
static Task< UserGet (string userId)
 Gets the information about a specified user. More...
 
static Task< UserListGetFriends ()
 Gets the friend list of the current user. More...
 
static Task< UserRelationResultGetUserRelations (string[] userIds)
 Gets the relationship between the current user and other users. More...
 
static Task< LaunchFriendResultLaunchFriendRequestFlow (string userId)
 Launches the flow to apply for friendship with someone. More...
 
static Task< UserRoomListGetFriendsAndRooms ()
 Gets the friends of the logged-in user and the rooms the friends might be in. More...
 
static Task< UserRoomListGetNextUserAndRoomListPage (UserRoomList list)
 Gets the next page of user and room list. More...
 
static Task< UserListGetNextUserListPage (UserList list)
 Gets the next page of user list. More...
 
static Task< PermissionResultGetAuthorizedPermissions ()
 Gets authorized permissions. More...
 
static Task< PermissionResultRequestUserPermissions (string[] permissionList)
 Requests user permissions. The user will received a pop-up notification window. More...
 
static Task< EntitlementCheckResultEntitlementCheck (bool killApp=true)
 Checks whether the current user is entitled to use the current app. More...
 

Detailed Description

Account & Friends service allows developers to access the info of a specified account, get the friends list of the currently logged-in users, send friend requests, and more.

Member Function Documentation

◆ GetAccessToken()

static Task< string > GetAccessToken ( )
inlinestatic

Returns an access token for this user.

Note
User's permission is required if the user uses this app firstly.
Returns
The access token for the current user.

◆ GetLoggedInUser()

static Task< User > GetLoggedInUser ( )
inlinestatic

Gets the information about the current logged-in user.

Returns
The User structure that contains the details about the user.

◆ Get()

static Task< User > Get ( string  userId)
inlinestatic

Gets the information about a specified user.

Note
The same user has different user IDs for different apps.
Parameters
userIdThe ID of the user.
Returns
The User structure that contains the details about the specified user.

◆ GetFriends()

static Task< UserList > GetFriends ( )
inlinestatic

Gets the friend list of the current user.

Note
Friends who don't use this app won't appear in this list.
Returns
The friend list of the current user.

◆ GetUserRelations()

static Task< UserRelationResult > GetUserRelations ( string[]  userIds)
inlinestatic

Gets the relationship between the current user and other users.

Parameters
userIdsThe list of user IDs. The request queries the current user's relationship with specified users. A single request can pass no more than 20 user IDs.
Returns
UserRelationResult which is a dictionary of user relationships.

◆ LaunchFriendRequestFlow()

static Task< LaunchFriendResult > LaunchFriendRequestFlow ( string  userId)
inlinestatic

Launches the flow to apply for friendship with someone.

Parameters
userIdThe ID of the user that the friend request is sent to.
Returns
LaunchFriendRequest that indicates whether the request is sent successfully.

◆ GetFriendsAndRooms()

static Task< UserRoomList > GetFriendsAndRooms ( )
inlinestatic

Gets the friends of the logged-in user and the rooms the friends might be in.

Returns
UserRoomList that contains the friend and room data. If a friend is not in any room, the room field will be null.

◆ GetNextUserAndRoomListPage()

static Task< UserRoomList > GetNextUserAndRoomListPage ( UserRoomList  list)
inlinestatic

Gets the next page of user and room list.

Parameters
listThe user and room list from the current page.
Returns
The user and room list from the next page.

◆ GetNextUserListPage()

static Task< UserList > GetNextUserListPage ( UserList  list)
inlinestatic

Gets the next page of user list.

Parameters
listThe user list from the current page.
Returns
The user list from the next page.

◆ GetAuthorizedPermissions()

static Task< PermissionResult > GetAuthorizedPermissions ( )
inlinestatic

Gets authorized permissions.

Returns
A struct containing the access token and permission list. The UserID field is empty so do NOT use it.

◆ RequestUserPermissions()

static Task< PermissionResult > RequestUserPermissions ( string[]  permissionList)
inlinestatic

Requests user permissions. The user will received a pop-up notification window.

Parameters
permissionListThe list of permissions to request. You can use constants in Pico.Platform.Models.Permissions. The permissions includes:
  • user_info: the permission to get the user's basic information, such as the nickname and profile picture.
  • friend_relation: the permission to get the user's friend list and invitable users.
  • sports_userinfo: the permission to get the user's information set in the sport center.
  • sports_summarydata: the permission to get a summary of the user's exercise data.
Returns
A struct containing the access token and permission list.

◆ EntitlementCheck()

static Task< EntitlementCheckResult > EntitlementCheck ( bool  killApp = true)
inlinestatic

Checks whether the current user is entitled to use the current app.

If the user is not entitled, the system will close the app and show a dialog box to remind the user to buy the app from the PICO Store. For customizations, you can set param killApp to false and then customize the dialog.

Parameters
killAppDetermines whether the system closes the app if the user fails to pass the entitlement check. The default value is true.
Returns
The entitlement check result.