DEVELOPING NFC APPS for BLACKBERRY
Total Page:16
File Type:pdf, Size:1020Kb
22 March 2014 1 DEVELOPING NFC APPS for BLACKBERRY NFC Forum, Developers Showcase March 21st, 2014 Larry McDonough, Principal Evangelist @LMCDUNNA 22 March 2014 2 CONTENTS • Development on BlackBerry • BlackBerry NFC Support • 5 most common use cases • NFC Demos • Q & A 22 March 2014 3 First, Some Stats… • A mobile device management leader with global enterprise customer base exceeding 80,000 • 30,000+ BES 10 commercial & test servers installed • 250,000+ BBM Channels globally since launch • 40+ Million newly registered Android/iOS BBM users in first 60 days • 665+ carriers and distribution partners offering BlackBerry products and services in more than 175 countries around the world 22 March 2014 4 High Level Architecture Native C++ & HTML5 & Android Cascades UI WebWorks Runtime BlackBerry Platform & Services (BlackBerry Enterprise Service 10, Push, Payments, BBM, Invocation Framework, Share Framework, Maps, …) BlackBerry 10 OS Support for NFC in the Android Runtime is coming in 10.3 22 March 2014 5 Strong & Growing Ecosystem Managing corporate... and personal apps Broad range of app dev libraries Wide choice of HTML5 C/C++ C++/Qt Java Android programming BlackBerry Native SDK Cascades Runtime languages WebWorks™ 22 March 2014 6 Top Partners 22 March 2014 7 BlackBerry World • In over 170 Markets • Free to register • Free to submit upgrade • 70/30 revenue share • Credit card, PayPal, Carrier Billing • 5+ Billion apps downloaded 22 March 2014 8 http://developer.blackberry.com • Tools, samples, documentation, Forums… • HTML5 / WebWorks • C, C++, Native SDK • Cascades UI Framework • Android • Frameworks Partners: • Appcelerator, Cordova, dojo, jQuery Mobile, Marmalade, Qt, Sencha Touch, Unity 22 March 2014 9 BlackBerry NFC Support 22 March 2014 10 CONTENTS • What is NFC? (skipped for this audience!) • NFC Tags • Peer to Peer • Card Emulation • Virtual Target (Host Card) Emulation • Reading Contactless Cards • APIs & Built-in Apps Support 22 March 2014 11 About NFC Tags Memory Cards that store data App takes action in Have a contactless response to the message interface Read by a device termed “the Reader” 22 March 2014 12 About NFC Tags 4 standard NFC Forum tag types Message format is Various tag capacities standard (NDEF) Standard message Custom types types include Smart (“external”) allowed Poster, Text, URI 22 March 2014 13 About Tag Circuitry 22 March 2014 14 Field Detection and Power 22 March 2014 15 Demo 1 – NFC Business Card Front Back • No coding or client app necessary • Uses standard URL message format • Leverages browser to take user to my eBusiness Card site • Backend server code helps me track who I met, who downloaded my vcard, etc. w/QR Code w/NFC Tag For iOS users For real smartphone users 22 March 2014 16 Demo 1 – NFC Business Card After scanning tag, developers can: • Add my vcard to their address book which includes usual stuff plus: • LinkedIn URL, • Twitter handle, • Slide Share link, • BlackBerry Dev Blog link, • My Blogger link, etc. • Request a device, Register as a vendor, and visit BlackBerry dev site 22 March 2014 17 Demo 2 – NFC Fun Run Start timer Run! Stop timer Have a nice cup of tea 22 March 2014 18 Register with Invocation Framework <invoke-target id="com.example.NfcRaceTime"> <type>APPLICATION</type> <filter> <action>bb.action.OPEN</action> <mime-type>application/vnd.rim.nfc.ndef</mime-type> <property var=“uris” value=“ndef://4/my.rim.com/myrecordtype”/> </filter> </invoke-target> 22 March 2014 19 Client action C++ and Qt bb::system::InvokeManager* _invokeManager = new bb::system::InvokeManager(); void App::receivedInvokeRequest( const bb::system::InvokeRequest& request) { QByteArray data = request.data(); QtMobilitySubset::QNdefMessage ndefMessage = QtMobilitySubset::QNdefMessage::fromByteArray(data); handleNdefRequest(ndefMessage); } 22 March 2014 20 CONTENTS • What is NFC? (skipped for this audience!) • NFC Tags • Peer to Peer • Card Emulation • Virtual Target (Host Card) Emulation • Reading Contactless Cards • APIs & Built-in Apps Support 22 March 2014 21 What is Peer to Peer NFC? Transfer data from one device to another • Share information just by touching Any kind of data • Photos, music files, address book contacts are typical examples For larger items let NFC negotiate a Bluetooth connection • No need for the usual BT pairing process • Simple! 22 March 2014 22 What is Peer to Peer NFC? Select object to share Touch devices! NFC ( and maybe Bluetooth) Magic Bask in the admiration! 22 March 2014 23 Share from QML InvokeActionItem { id: sharedNdefData query { mimeType: "application/vnd.rim.nfc.ndef" invokeActionId: "bb.action.SHARE" } } onShowing: { // make NDEF message as byte array in C++ sharedNdefData.data = _ndefFactory.getNdefVcardMessage(sendVcard.ndefFirstName, sendVcard.ndefLastName, sendVcard.ndefAddress, sendVcard.ndefEmail, sendVcard.ndefMobile); } 22 March 2014 24 Share from C++ NfcShareManager *_nfcShareManager = new NfcShareManager(); ... void NfcSharing::fileShareContentChanged(QString paths) { NfcShareFilesContent request; QList<QUrl> urls; ... // Construct a list of local file URLs from file paths ... request.setFileUrls(urls); // share mode File means Bluetooth connection handover _nfcShareManager->setShareMode(bb::system::NfcShareMode::File); NfcShareSetContentError::Type rc = _nfcShareManager->setShareContent(request); } 22 March 2014 25 CONTENTS • What is NFC? (skipped for this audience!) • NFC Tags • Peer to Peer • Card Emulation • Virtual Target (Host Card) Emulation • Reading Contactless Cards 22 March 2014 26 What are we Emulating? We are emulating Smart Cards Almaden Valley Health Club Larry McDonough Member Since: 2/11/2005 Membership & Credit Cards ID Cards Loyalty Cards 22 March 2014 27 What are Smart cards? Can run special A small Processor, OS, apps called Almaden Valley computer file system Health Club ‘applets’ Contacts and/or Embedded in a Larry McDonough Secure contactless Member Since: 2/11/2005 plastic card interface 22 March 2014 28 Smart Cards & Readers Almaden Valley Power Health Club Communications Larry McDonough Member Since: 2/11/2005 Smart Card Reader With contact-based slot and contactless interface (NFC) 22 March 2014 29 General Architecture 22 March 2014 30 BlackBerry Architecture 22 March 2014 31 Card Emulation In Use Touch handset to a reader Reader communicates directly with SE Optionally be notified of transaction Admire your purchase 22 March 2014 32 Interact with Secure Element ... rc = nfc_se_session_open_logical_channel(hSESession, the_aid, sizeof(the_aid), fcpResponseType, &seChannel, &openResponseLen); ... rc = nfc_se_channel_transmit_apdu( seChannel, the_apdu, apdu_size, &exchangeResponseLen ); ... rc = nfc_se_channel_get_transmit_data(seChannel, result, &nReceiveAPDUBufferSize)); ... 22 March 2014 33 Transaction Notification ... <invoke-target id="com.example.NfcTool.tl"> <entry-point>1</entry-point> <type>APPLICATION</type> <filter> <action>bb.action.NOTIFY</action> <mime-type>application/vnd.bb.nfc_transaction</mime-type> <property var="uris“ value="aid://SIM/6e.66.63.74.65.73.74.30.31/"/> </filter> </invoke-target> ... 22 March 2014 34 NFC Payments EcoSystem Financial Retail Institutions Transport MNOs Secure Secure Provisioning Transactions (e.g. TSM) (e.g. EMV) Secure Payments (NFC) 22 March 2014 35 CONTENTS • What is NFC? (skipped for this audience!) • NFC Tags • Peer to Peer • Card Emulation • Virtual Target (Host Card) Emulation • Reading Contactless Cards • APIs & Built-in Apps Support 22 March 2014 36 What is Virtual Target Emulation? Touch handset to a reader Reader communicates with BlackBerry 10 App Application completes transaction Smile at new allocation of loyalty points! 22 March 2014 37 Fool that Reader! • Virtual target emulation makes your smartphone seem just like an NFC tag or card • The reader cannot tell them apart • Of course you cannot set the UID of the emulated target – that is not under your control 22 March 2014 38 Emulating an NDEF Tag ... nfc_ndef_record_t *ndefRecord = makeCustomRecord(QString("my.rim.com"), QString("myrecordtype"), tagData); rc = nfc_create_ndef_message(&_emulateNdefMessage); rc = nfc_add_ndef_record(_emulateNdefMessage, ndefRecord); rc = nfc_start_ndef_tag_emulation(_emulateNdefMessage); ... 22 March 2014 39 CONTENTS • What is NFC? (skipped for this audience!) • NFC Tags • Peer to Peer • Card Emulation • Virtual Target (Host Card) Emulation • Reading Contactless Cards • APIs & Built-in Apps Support 22 March 2014 40 What is it? Read data from physical (plastic) contactless cards • Right into your application Reduce manual data entry • e.g., credit card number Make card usage tracking more convenient • e.g., view card use history or balance on BlackBerry 10 smart phone 22 March 2014 41 What can you do with it? 1. Card details 2. User presents 3. App reads details required contactless card from card and completes form 22 March 2014 42 How do you do this? Exactly *how* depends on the card type • A credit card is not the same as an ID card • Transit cards are not all the same Exchange APDUs with the card • Response APDUs will contain the data you want • You have to send the right command APDUs though Touch card to BlackBerry to fill in form • Details for credit cards are defined in the EMV specifications 22 March 2014 43 How do you do this? Touch handset to a card BlackBerry 10 App acts as reader APDU ‘conversation’ with card yields data User delighted with result of your thoughtful feature 22 March 2014 44 Code Example ... rc = nfc_register_tag_readerwriter(TAG_TYPE_ISO_14443_4);