In my talk this week I demonstrated a simple library for sharing a single Uri over NFC. I’ve now completed packaging it up and it is available on NuGet – https://www.nuget.org/packages/InTheHand.Phone.Nfc/
This is a very simple component to use in your app requiring just three lines of code to call. It requires the Windows Phone Toolkit from which it uses page transitions, if you don’t already have this in your project NuGet will add it for you. It also requires you to add the Proximity capability in your app metadata. The Windows Phone Emulator exposes a null NFC device so it is possible to interact with this feature on the emulator (it just won’t send anything). The look and feel of the task has been designed to match the platform so it will look instantly familiar and supports both the light and dark themes.
To share a Uri from your app you’ll need to execute the following:-
Add the InTheHand.Phone.Nfc package via NuGet
Add the ID_CAP_PROXIMITY capability to your WMAppManifest.xml
Add the following code when you want to share a Uri:-
InTheHand.Phone.Tasks.ShareNfcLinkTask snlt = new InTheHand.Phone.Tasks.ShareNfcLinkTask();
snlt.LinkUri = new Uri(“http://peterfoot.net“);
Obviously setting the LinkUri to whatever URI you want to share. This could be a web link or a custom URI which performs some task in your app.
At the moment the resources in the library are not localised beyond English although I hope to add this soon.
This is the first in a set of related “Charming” libraries for Windows Phone. I’ll be adding more to NuGet shortly. Hopefully the reason for the name will become clearer too…