How do I set up an XBox Live Sign In using Xamarin Forms?

BillyMartinBillyMartin USMember ✭✭✭

**I have a xamarin forms game that uses all the platforms including xbox. Now Microsoft want me to include an xbox live sign in. I've seen a couple of uwp examples but can't figure out how to make them work in xamarin forms.

Here is the example I've seen along with his advice for uwp:**

_After much research, and reviewing the helpful answers above, I found out the following two ways to get a Windows Universal app to be approved by the Microsoft Store to work on Xbox One. The second method (see below) shows how to do this by displaying the gamertag in the application.

To get the app approved for Xbox without using "Xbox Live" (and displaying the gamertag), you will need to go through the "Concept Approval" process. You can get started by filling out the [email protected] application

Alternatively, you can get the app approved by integrating "Xbox Live" into your UWP application by doing the following to display the gamertag in your app:

Make sure your project (right click on your project->Application) is set to a min version of "Windows 10 Creators Update (10.0; Build 15063)" and a Target version of "Windows 10 Fall Creators Update (10.0; Build 16299)" -- otherwise, the reference to "Microsoft.Xbox.Services.winmd" won't appear when you add the NuGet package below.

Inside Visual Studio, use Nuget Package Manager, to add Microsoft.Xbox.Live.SDK.WinRT.UWP

In your project, created an xboxservices.config file following Section 6 of these instructions.

Create a TextBlock control to display the gamertag. In my case, I put it at upper left side of the app's screen, and passed it in to the following function to display the gamertag:
_

       public static async void InitializeXboxGamer(TextBlock gamerTagTextBlock)
        {
            try
            {
                XboxLiveUser user = new XboxLiveUser();
                SignInResult result = await user.SignInSilentlyAsync(Window.Current.Dispatcher);
                if (result.Status == SignInStatus.UserInteractionRequired)
                {
                    result = await user.SignInAsync(Window.Current.Dispatcher);
                }
                gamerTagTextBlock.Text = user.Gamertag;
                gamerTagTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
            catch (Exception ex)
            {
                // TODO: log an error here
            }
        }

_I called this function at the end of my MainPage() constructor.

You must call this function on all supported platforms (including Windows 10) to get store approval._

Answers

  • batmacibatmaci DEMember ✭✭✭✭✭

    thank you for the information and great to see others doing Xbox apps and games also. Did you use cocosharp to create your game? Xamarin.forms doesnt handle mouse pad on xbox, how did you achieve this?

  • BillyMartinBillyMartin USMember ✭✭✭

    My game was a dice game that used dice pngs and kept the scores in lists, so I did not need cocsharp. Xbox automatically mapped the left controller joystick as the mouse x and y. The A button was automatically mapped as the left mouse click.

    Hope that helps!

Sign In or Register to comment.