gpt4 book ai didi

c# - UWP/C# 应用程序如何登录 XBox 用户并显示玩家代号?

转载 作者:太空狗 更新时间:2023-10-30 01:30:00 25 4
gpt4 key购买 nike

我正在尝试将 UWP 应用程序(用 C#/XAML 编写)重新提交到 Microsoft 商店,以便它除了以前支持的 Windows 桌面和 Windows Phone 之外还支持“Windows 10 Xbox”。我可以在开发人员模式下在我的 Xbox One 控制台上部署(使用 Visual Studio 2017)和运行该应用程序,没有任何问题。当我提交到商店时,出现以下错误:

Because your game uses Xbox Live, it must:
· Create at least one active user and sign the user into Xbox.
· Display the user’s Xbox gamertag as the primary display and profile name.

Please add this behavior and resubmit your game.

我正在寻找一个最小的 C#/XAML 示例来说明如何解决此提交问题。

The post on "Accessing Raw Gamer Profile Picture"似乎表明我可以通过执行以下操作来处理登录:

if (App is running on Xbox)
{
XboxLiveUser user = new XboxLiveUser();
SignInResult result = await user.SignInAsync();
}

但我不确定这是否正确,或者我如何确定该应用程序正在 Xbox 上运行。

此外,我想知道应该如何以及在何处显示用户的玩家代号。我可以只在 XAML 中的任何位置显示它吗?或者,是否需要调用一些特殊的 Xbox API 来显示它?

简而言之,我需要一个非常简单的 C#/XAML 示例,展示如何执行检查应用程序是否在 Xbox 上运行、登录用户以及在适当位置显示用户玩家代号等最低要求,这样我就可以满足 Microsoft Store 的要求。

更新:我做了以下事情:

使用 Nuget 包管理器,我安装了 Microsoft.Xbox.Live.SDK.WinRT.UWP\

在项目中,我在Section 6 of these instructions 之后创建了一个xboxservices.config 文件。

我在屏幕的左上角创建了一个 TextBlock 控件,并将其传递给以下函数以显示玩家代号:

public static async void InitializeXboxGamer(TextBlock gamerTagTextBlock)
{
if (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily.Contains("Xbox"))
{
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;
}
else
{
gamerTagTextBlock.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
}
}

然而,这仍然未能通过提交测试,并出现以下错误:

App Policies: 10.13.5 Xbox Live Active User and Gamertag

Notes To Developer

Because your game uses Xbox Live, it must: · Create at least one active user and sign the user into Xbox. · Display the user’s Xbox gamertag as the primary display and profile name. Please add this behavior and resubmit your game. You can view the Xbox Live documentation for more information. Your game may not appear in the Creators Collection until this has been resolved.

Tested Devices: Windows 10 Desktop, Windows 10 Xbox

关于我在这里做错了什么有什么想法吗?

最佳答案

经过大量研究并回顾了上面的有用答案,我发现了以下两种方式让 Windows 通用应用获得 Microsoft Store 批准以在 Xbox One 上运行。第二种方法(见下文)展示了如何通过在应用程序中显示玩家代号来执行此操作。

在不使用“Xbox Live”(并显示玩家代号)的情况下获得 Xbox 批准的应用,您需要通过 "Concept Approval"过程。您可以通过填写 ID@XBOX application 开始

或者,您可以通过将“Xbox Live”集成到您的 UWP 应用程序中,通过执行以下操作在您的应用程序中显示玩家代号来获得应用程序的批准:

确保您的项目(右键单击您的项目->应用程序)设置为“Windows 10 Creators Update (10.0; Build 15063)”的最低版本和“Windows 10 Fall Creators Update (10.0; Build 15063)”的目标版本。 Build 16299)”——否则,当您在下面添加 NuGet 包时,将不会出现对“Microsoft.Xbox.Services.winmd”的引用。

在 Visual Studio 中,使用 Nuget Package Manager 添加 Microsoft.Xbox.Live.SDK.WinRT.UWP

在您的项目中,在 Section 6 of these instructions 之后创建了一个 xboxservices.config 文件.

创建一个 TextBlock 控件来显示玩家代号。在我的例子中,我将它放在应用程序屏幕的左上角,并将其传递给以下函数以显示玩家代号:

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
}
}

我在 MainPage() 构造函数的末尾调用了这个函数。

您必须在所有支持的平台(包括 Windows 10)上调用此函数才能获得商店批准。

然后,转到developer.windows.com,登录,选择你的游戏,选择“服务”,选择“Xbox Live”,点击“为你的测试环境授权Xbox Live账户”,这样你就可以在本地测试了.

此外,请务必单击“Xbox Live”部分中的“测试”按钮。

关于c# - UWP/C# 应用程序如何登录 XBox 用户并显示玩家代号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48257456/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com