Windows Phone 8 NFC Quickstart

2,843 views
2,730 views

Published on

The quick walkthrough will show you how to create your first NFC app for Windows Phone 8.

The NearSpeak app (available soon in the WP Store) writes voice NFC tags - touch the tags again to hear your message! Leave notes for your partner, reminders for yourself, or use them for a fun public social experiment.

This hands-on tutorial will show you how to create this app. You will see how to write a LaunchApp tag using the NDEF Library for Proximity APIs, how to recognize text spoken by the user, and how to use the speech synthesizer to let the phone read the text again.

Note that the instructions require basic knowledge of Windows Phone development.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,843
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
64
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Windows Phone 8 NFC Quickstart

  1. 1. Windows Phone 8 NFCQuickstart – NearSpeakAndreas Jakl[@mopius]nfcinteractor.comTechnology WizardNokia 1 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl NFC Forum and the NFC Forum logo are trademarks of the Near Field Communication Forum.
  2. 2. Near Field Communication NearSpeak2 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  3. 3. Near Field Communication3 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  4. 4. Scenarios Connect Devices Exchange Digital Objects Acquire Content4 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  5. 5. Windows Phone 8 + Proximity APIs Windows 8 Documentation Win8: bit.ly/ProximityAPI WP8: bit.ly/ProximityAPIwp85 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  6. 6. NearSpeak nearspeak.at6 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  7. 7. NearSpeak Record a Write to an Tap the tag to voice message NFC tag launch the app & hear the text!7 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  8. 8. General Project Setup1 Add Capabilities: Proximity, Microphone, Speech Recognition, Networking Requirement: NFC Connect to HW2 Initialize ProximityDevice Detect devices in range _device = ProximityDevice.GetDefault(); Publish & subscribe to messages3 Initialize Speech Recognizer & Synthesizer _recognizer = new SpeechRecognizer(); _synthesizer = new SpeechSynthesizer();8 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  9. 9. UI Design9 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  10. 10. Listen4 Text recognition (Speech-to-Text) var recoResult = await _recognizer.RecognizeAsync(); MessageBox.Show(string.Format("You said "{0}"n Please touch a tag to write the message.", recoResult.Text));10 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  11. 11. Data on an NFC Tag LaunchAppArguments[speech text]WindowsPhone app ID{0450eab3-92…} Data Encapsulated in Encoded through Stored on NDEF Record(s) NDEF Message NFC Forum NFC Forum Tag Tag Type Platform11 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl NDEF = NFC Data Exchange Format, Container image adapted from s_volenszki (Flickr), released under Creative Commons BY-NC 2.0
  12. 12. NDEF.codeplex.com Create NDEF Reusable Parse information messages & records NDEF from raw byte arrays (standard compliant) classes Fully documented Open Source LGPL license (based on Qt Mobility)12 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  13. 13. Supported Record Types Geo tags Smart Poster Social tags URI SMS tags Text Telephone call LaunchApp Android Application Record (AAR) Nokia Accessories Record13 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl Why use the library for “Talking Tags”? Creating LaunchApp records is easier, and you can also send them to other phones and not only write to a tag.
  14. 14. NDEF Library5 Use NuGet package manager to install NDEF Library for Proximity APIs14 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  15. 15. Write NFC Tags6 Create LaunchApp Message (in button call-back method) var record = new NdefLaunchAppRecord {Arguments = recoResult.Text}; record.AddPlatformAppId("WindowsPhone", "{...}"); var msg = new NdefMessage {record};7 Write to the next tag _device.PublishBinaryMessage("NDEF:WriteTag", msg.ToByteArray().AsBuffer(), MessageWrittenHandler);15 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  16. 16. Write NFC Tags8 NFC message written to a tag? Inform user private void MessageWrittenHandler( ProximityDevice sender, long messageId) { Dispatcher.BeginInvoke(() => MessageBox.Show( "Message written")); }16 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  17. 17. Speak When Launched9 App launched from a tag? Speak the stored text! protected override async void OnNavigatedTo( NavigationEventArgs e) { base.OnNavigatedTo(e); if (NavigationContext.QueryString.ContainsKey( "ms_nfp_launchargs")) { await _synthesizer.SpeakTextAsync( NavigationContext.QueryString ["ms_nfp_launchargs"]); } }17 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  18. 18. Nfc Interactor for Windows Phone 818 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  19. 19. nfcinteractor.com19 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  20. 20. Near Field Communication NearSpeak20 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
  21. 21. Thank You. NFC Introduction bit.ly/NfcIntroAndreas Jakl Related Presentations[@mopius] Windows (Phone) 8 NFC App Scenarios bit.ly/NFCAppScenariosnfcinteractor.com NFC Development on the Windows 8 PlatformTechnology Wizard bit.ly/Win8NFCNokia NFC Development with Qt on Symbian and MeeGo bit.ly/NfcDevelopment 21 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl

×