Turn-Based Games

Unfortunately, Facebook does not provide rich turn-based matchmaking API like Game Center(IOS) or Play Service(Android). This  means that a developer should implement turn-based matchmaking logic by himself or use another 3-rd party solutions. However, turn-based games can effectively use requests as a notification mechanism. When one player completes a turn, he can send a request to his opponent prompting him to take his turn. This helps to keep players engaged with the game.

Turn based game sending a `turn` request

 

Turn based game using a `turn` request to notify a player that it's his turn.

 

The following code snippet shows how to send a turn notification. By default, the sender is presented with a multi-friend selector allowing him to select maximum of 50 recipients.

SPFacebook.instance.SendTrunRequest("Smaple title", "Smaple Message");

 

Sending requests to a specific recipient and providing additional request data:

Note: If the to field is specified, the sender will not be able to select additional recipients.

string FriendId = "1405568046403868";
		SPFacebook.instance.SendTrunRequest("Sample Titile", "Sample message", "some_request_dara", new string[]{FriendId});

 

The other request handling part is the same as for the Game Gifting API and is described here:

 

You can read more about the Facebook App requests at the Facebook Official Documentation. The implementation example can be found at the FacebookTurnBasedAndGifts example scene.