question

Prabhjot Singh avatar image
Prabhjot Singh asked

is there Any Efficient way of finding Count of friends?

I am creating a game where i want to show user friend.

Problems : if user has too many friends( 500+ ) and whenever they see friend list.. my app will query for ( Getfriendlist ) function.

Requirement : is there any way so i can get the friends Count for a particular user so if there is no update in friends list, or is there any way to check is there any change in Friend list before quering the whole list? So,It wont be calling the function for unnecessary load

Friendsgame manager
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

PlayFab doesn’t natively support requesting the count of friends. You can implement it yourself. You can use Read Only Player Data to store counts of friends and update this value via CloudScript when players call Add/Remove friends API. So you can get the current count of friends.

4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Prabhjot Singh avatar image Prabhjot Singh commented ·

What if some one from facebook or other service loggen in and added as friend to other users? the Count will not be updated.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Prabhjot Singh commented ·

Yes, PlayFab can only request the friends list from Facebook or other services but can’t store it. To protect user’s privacy, storing other platforms’ friends lists isn’t allowed and appropriate. So we can only monitor adding/removing friends operations that from PlayFab. If you would like to get other platforms’ friends lists, you can only request them in real time. For monitoring adding/removing friends operations, you can filter other platforms’ friend lists let your players choose whether or not to add the friends from other services via PlayFab API. Or you can try to find other solutions from APIs of Facebook or other services.

0 Likes 0 ·
Prabhjot Singh avatar image Prabhjot Singh Sarah Zhang commented ·

I have one solution that is not totally efficient but still might work. I need your thoughts on that.

Solution : when a user query getfriendlist for the first time, they get the list and then save a count on the playfab account. Now from the second times user calls a cloudscript that query the least info from Getfriendlist (disabling profile constraint and any other parameter) and checks the counts. if the count is higher it sends back the data to user otherwise sends nothing.

Here, I think playfab server wont have a hard time quering 500 or 1000 users .. but sending them to user every time would be heavy taxing on my limits.

Will this be a better approach ?

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.