Sign In Register

How can we help you today?

Start a new topic
Answered

Match Friends only

Hello,


We would like to match facebook friends only in order to create a challenge.

Is there a platform recommended way of doing this?


Best Regards


Best Answer

Hi Milutin,


You could perform a ListGameFriendsRequest, then in the response, check for any of the friends that contain a Facebook externalId and if they do, use a SparkRequest to send a CreateChallengeRequest using the returned ids in the "usersToChallenge" field in that request.


"friends": [
  {
   "displayName": "Patricia Alaafhjaeijbf Greenesky",
   "externalIds": {
    "FB": "138131196586218"
   },
   "id": "5735c038808eb904a0d68f54",
   "online": false
  },


Another method would be to add your friends to a team, then in Cloud Code use "var memberIds = Spark.getTeams().getTeam(myTeamId).getMemberIds();" to return an array of the team member ids, you could then use the returned array as the "usersToChallenge" field for the CreateChallengeRequest. Hopefully that helps, let me know if you have any further questions.


Thanks,

Liam



Answer

Hi Milutin,


You could perform a ListGameFriendsRequest, then in the response, check for any of the friends that contain a Facebook externalId and if they do, use a SparkRequest to send a CreateChallengeRequest using the returned ids in the "usersToChallenge" field in that request.


"friends": [
  {
   "displayName": "Patricia Alaafhjaeijbf Greenesky",
   "externalIds": {
    "FB": "138131196586218"
   },
   "id": "5735c038808eb904a0d68f54",
   "online": false
  },


Another method would be to add your friends to a team, then in Cloud Code use "var memberIds = Spark.getTeams().getTeam(myTeamId).getMemberIds();" to return an array of the team member ids, you could then use the returned array as the "usersToChallenge" field for the CreateChallengeRequest. Hopefully that helps, let me know if you have any further questions.


Thanks,

Liam


Hi Milutin, 

To reference ones social friends, the ListGameFriendsRequest is used. You could then use the createMatch() method of the SparkMultiplayer class to add these referenced players to a match. More can be seen on this here: https://docs.gamesparks.net/documentation/cloud-code-api/spark-cloud-code-api/sparkmultiplayer#createMatch

Best Regards, Patrick. 

Thanks Liam and Patrcik.


We were thinking about using match to match users but in essence, as you said, we can do it by using challenges and even more complex match criteria then those offered by using match (skill).  



Happy to be of help. I'll mark my last response as the answer to this post. If you have any further queries please don't hesitate to contact us.

Best Regards, Patrick. 

Login to post a comment