Detect if a common user interface is supported on the current device (UWP)

I created a UWP application for Windows 10 devices using C # / xaml. In the application, I have a sharing function that callsDataTransferManager.ShowShareUI()

This works on both desktop, tablet and mobile devices. But on my xbox, the above method does not start the common interface. And he does not throw any exceptions. After searching the Internet a bit, I found this article which says that a stock contract is not supported on xbox. And the general user interface is not displayed. But it gives a bad user interface.

So I have 2 options

  • Hide sharing button if device is xbox
  • Or, when the user clicks on sharing, a pop-up window appears in which the function is not supported

After hours of searching, I still have not found a reliable way to determine if my device is xbox. Microsoft does not recommend trying to identify the type of device. Instead, we should check to see if the API is supported using ApiInformation.IsTypePresentor ApiInformation.IsApiContractPresent. See here for more details.

But in my case, the API is present. So IsTypePresent returns true. I'm not sure which parameter I should pass for IsApiContractPresent in my script.

In short, I need a reliable way to determine if my device is xbox or determine if the common user interface is supported on my device. Does anyone know how to do this?

+4
1

Windows 10 RS1 IsSupported DataTransferManager :

, Xbox RS1 , , , .

if (DataTransferManager.IsSupported())
{
      //Do sharing
}
else
{
      //Other thing
}
+2

Source: https://habr.com/ru/post/1670505/


All Articles