The game invite task is used to show a game invite screen that enables the user to invite players to a multiplayer game session that is in progress on a Windows Phone device. The invitation is sent asynchronously.
Caution
The game invite task works only when called from within a game that is approved for release on Xbox LIVE on Windows Phone.
When the user finishes sending the invite, cancels out of the task, or an error occurs, the task’s Completed
event is raised.
The GameInviteTask
should be defined as a field in your class, like so:
readonly GameInviteTask gameInviteTask = new GameInviteTask();
Subscribe to the GameInviteTask.Completed
event within your class constructor, as shown:
gameInviteTask.Completed += new EventHandler<TaskEventArgs>(HandleCompleted);
The GameInviteTask
allows you to specify a unique session ID. The only information that another player needs to join an active game session is the session ID.
gameInviteTask.SessionId = "<session id>";
gameInviteTask.Show();
When the task’s Show
method is called, the built-in Game Invite app is launched, allowing the user to email recipients using either a gamer tag or an email address.
Note
Without a valid session ID, the Game Invite app is not able to send invitations.
The built-in Game Invite app is shown in Figure 14.28.
3.138.174.95