Skip to main content
Version: v3

Friends on Third-Party Platforms

Before continuing, please familiarize yourself with the general interfaces of the Friends module

Retrieving Friends on Third-Party Platforms

The following interface can be used to retrieve the current player’s friends (mutual followers) on third-party platforms (like TapTap) who have played the same game. Besides the friend list, the interface also returns a cursor. You can implement pagination by providing the cursor and a limit when performing the query. The players in the result can be sorted by online status (those who are online will be placed at the beginning).

The returned list of friends on the third-party platform will include each player’s ID, nickname, and profile picture on the platform. As mentioned above, only those who have played the same game (i.e., logged in to the game with their third-party account) will be included in the friend list. In general, those friends have logged in to the game with their third-party accounts that are based on the built-in account system, so the TDSFriendInfo of each player will be included in the friend list as well.

In special cases, if a friend is logged in with their third-party account without using the built-in account system, the friend will still be included in the friend list, but their TDSFriendInfo will be null. For example, assuming a game has two variations of APKs, variation A logs players in with F using the built-in account system and supports the Friends service while variation B also logs players in with F but without using the built-in account system and doesn’t support the Friends service. Player D and Player E are friends on F and they each use a different variation of the game (Player D uses the variation A) but both log in with F. Now if Player D retrieves their friends on F with the following interface, the returned list will include Player E, but the TDSFriendInfo of Player E will be null.

// First query
string platform = "taptap";
string cursor = null;
// Defaults to 50; no larger than 500
int limit = 50;
// Sort by online status
SortCondition sortCondition = SortCondition.OnlineCondition
ThirdPartyFriendResult result = await TDSFriends.QueryThirdPartyFriendList(platform, cursor, limit, condition: sortCondition);

ReadOnlyCollection<ThirdPartyFriend> friends = result.FriendList;
foreach (ThirdPartyFriend friend in friends) {
string thirdPartyId = friend.Id;
string thirdPartyNickName = friend.Name;
string thirdPartyAvatarUrl = friend.Avatar;
TDSFriendInfo info = friend.FriendInfo;
}

// Pagination
string cursor = result.Cursor;
ThirdPartyFriendResult more = await TDSFriends.QueryThirdPartyFriendList(platform, cursor, limit, condition: sortCondition);

By default, the SDK will fetch the result from the local cache. To always fetch the result from the cloud, you can specify the caching strategy when performing the query. The SDK will always cache the result regardless of the caching strategy you specify. In other words, the caching strategy only affects whether the cache will be read. It won’t affect whether the result will be cached.

ThirdPartyFriendResult result = await TDSFriends.QueryThirdPartyFriendList(platform, cursor, limit,
TDSFriends.ThirdPartyFriendRequestCachePolicy.OnlyNetwork, sortCondition);

At this moment, the following third-party platforms are supported:

  • taptap (Please submit a ticket to us to enable it)