Freigeben über


Add NFC to your Windows Store app

The Nokia 360 speaker sharing its Bluetooth pairing information with a Windows Phone. Photo: Windows 8 app developer blog

The indispensable Windows 8 app developer blog has a nice overview of programming NFC in your Windows Store apps. Priya Dandawate walks you through the deets in this excellent post.

Here’s a little C# snippet to whet the appetite:

    1: private void InitializeProximityDevice()
    2: {
    3:  
    4: Windows.Networking.Proximity.ProximityDevice proximityDevice;
    5:     proximityDevice = Windows.Networking.Proximity.ProximityDevice.GetDefault();
    6:  
    7:     if (proximityDevice != null) {
    8:         proximityDevice.DeviceArrived += ProximityDeviceArrived;
    9:     
   10:     }
   11:     else
   12:     {
   13:         // No NFC radio on the PC, display an error message
   14:     }
   15: }
   16:  
   17: private void ProximityDeviceArrived(Windows.Networking.Proximity.ProximityDevice device)
   18: {
   19:             // Let the user know we’re ‘Writing to Tag’
   20:  
   21: }

 

 

Technorati Tags: Windows,Windows 8,Windows Store app,NFC