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.

Advertisements

4 thoughts on “Code to send game invite to multiple user in Windows Phone

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s