Code to send game invite to multiple user in Windows Phone

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,

image

Then Create instance of GameInviteTask and attach completed event in the constructor of the page as below,

image

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.

image

In completed event handle user action. On selection of user shown appropriate message as below,

image

User will configure Email Id as below,

image

On user selection cancel, message will be shown in message box as below.

image

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.

4 responses to “Code to send game invite to multiple user in Windows Phone”

  1. Wow, that brings back some memories… 🙂

  2. […] Read original post by Dhananjay Kumar at Debug Mode […]

  3. […] Read more about Code to send game invite to multiple user in Windows Phone by Dhananjay Kumar @ debug_mode.net […]

  4. […] Code to send game invite to multiple user in Windows Phone […]

Leave a comment

Create a website or blog at WordPress.com