microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

ProximityDevice NFC events not triggered / NFC doesn't work at all

Open baaaaif opened this issue 1 year ago • 3 comments

Describe the bug

We have an app that we migrated from UWP to WinUI 3 a while ago. Unfortunately, we discovered that with the WinUI 3 app the ProximityDevice NFC feature no longer triggers events / no longer works at all.

We use simple code that can be found in many examples and have set <DeviceCapability Name="proximity"/>

var proximityDevice = Windows.Networking.Proximity.ProximityDevice.GetDefault();
var messageSubscriptionId = proximityDevice.SubscribeForMessage("NDEF", (device, message) =>
{
    Console.WriteLine(message.Data.ToArray());
});

this works in UWP and doesn't work in WinUI3 See min Repo examples Works: https://github.com/minze-it/BlankProximityUWP Doesn't work: https://github.com/minze-it/BlankProximityMaui

Steps to reproduce the bug

  • Start min repo apps
  • Click Button
  • Try read a NDEF 213/215/216 Tag which contains a NDEF message

Expected behavior

SubscribeForMessage delegate handler is invoked

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.4.5: 1.4.240411001

Windows version

Windows 11 (22H2): Build 22621, Windows 11 (21H2): Build 22000

Additional context

Also tested with 1.5 p1. No difference

baaaaif avatar Feb 22 '24 18:02 baaaaif

Because anything under the Windows namespace is a Windows feature, then I would think that it would be faster to obtain support elsewhere. This would be a Windows issue after all. The fact that you are attempting to access ProximityDevice in a WinUI 3 application should be inconsequential. While I can't personally test it right now, you should have the exact same problem in any desktop application. WinUI 3 is just a library that runs in the desktop environment.

DarranRowe avatar Feb 22 '24 22:02 DarranRowe

Because anything under the Windows namespace is a Windows feature, then I would think that it would be faster to obtain support elsewhere. This would be a Windows issue after all. The fact that you are attempting to access ProximityDevice in a WinUI 3 application should be inconsequential. While I can't personally test it right now, you should have the exact same problem in any desktop application. WinUI 3 is just a library that runs in the desktop environment.

Hi @DarranRowe, thank you for your quick reply.

It's the Windows namespace, but as I understand it, exclusively as part of the Windows Runtime. https://learn.microsoft.com/en-us/uwp/api/windows.networking.proximity.proximitydevice?view=winrt-22621

I assumed that when it comes to UWP and WinUI apps then this would be the correct place to go. Am I mistaken here? What would be the correct repository for WinRT Apis to report problems? https://github.com/microsoft/WindowsAppSDK/ will probably result in the same thing as the issue here, right?

At least it can't be https://github.com/dotnet/runtime

baaaaif avatar Feb 23 '24 06:02 baaaaif

For questions, the Microsoft Q&A site is the better option here. The C# and Universal Windows Platform (UWP) tags would help round things down. For reporting bugs, you would have to use the Feedback Hub app that comes as part of Windows.

Regarding whether this is the correct place to report it. You have to remember that WinUI 3 is just a library that is loaded into a desktop application. This repository only covers anything under the Microsoft.UI.Xaml namespace (and related namespaces like Microsoft.UI.Composition and Microsoft.UI.Content). Windows.Networking.Proximity.ProximityDevice falls outside of this scope, even if it is being used in a WinUI 3 application. While I am unable to personally test it, I believe that you would end up with the same issue if you just removed WinUI 3. So using ProximityDevice in a WinForms, WPF or even a Windows API application would give you the same issue as you are seeing now. There are still a few WinRT runtime classes that are not documented as being unusable from desktop applications that do not work correctly.

DarranRowe avatar Feb 23 '24 23:02 DarranRowe

Let's track this via microsoft/WindowsAppSDK#4356.

codendone avatar Apr 25 '24 19:04 codendone