You can send game invite to multiple users in Windows Phone using GameInviteTask chooser.
GameInviteTask chooser is used to send invitation to other users in multi-player game. It provides an invite screen to user where they can configure Email address of other users to send game invitation. Invitation will be sent by GameInviteTask chooser is in asynchronous manner.
GameInviteTask will launch invite screen and when user will complete configuring Email address of other user then complete event will get fired.
To work with GameInviteTask, you need to follow below steps
Very first you need to declare variable globally on the page as below,
Then Create instance of GameInviteTask and attach completed event in the constructor of the page as below,
Next you need to call the show method to launch invite screen application as per your business requirement. It may be on click event of a button. Session Id is string identifying particular network session.
In completed event handle user action. On selection of user shown appropriate message as below,
User will configure Email Id as below,
On user selection cancel, message will be shown in message box as below.
For your reference full source code is as below,
public partial class MainPage : PhoneApplicationPage { GameInviteTask gameInviteTask; public MainPage() { InitializeComponent(); gameInviteTask = new GameInviteTask(); gameInviteTask.Completed += new EventHandler<TaskEventArgs>(gameInviteTask_Completed); } private void Button_Click(object sender, RoutedEventArgs e) { gameInviteTask.SessionId = "your session id of the game"; } void gameInviteTask_Completed(object sender, TaskEventArgs e) { switch (e.TaskResult) { case TaskResult.OK: MessageBox.Show("Sent"); break; case TaskResult.Cancel: MessageBox.Show("Cancel"); break; case TaskResult.None: MessageBox.Show("Failed"); break; } } }
In this way you can send game invitation to multiple users. I hope this post is useful. Thanks for reading.
Follow @debug_mode
Leave a Reply