forked from chariotsolutions/phonegap-nfc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create GettingStartedBlackBerry10.md
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Getting Started with PhoneGap NFC on BlackBerry 10 | ||
|
||
Hardware & Software | ||
* OSX 10.10.5 | ||
* BB10 WebWorks SDK 2.2.0.15 | ||
* Cordova 5.5.3 | ||
* PhoneGap NFC 0.6.5 | ||
* BlackBerry Z10 running 10.3.1.156 | ||
|
||
Create the project and install the plugins | ||
|
||
cordova create nfc com.example.nfc HelloNFC | ||
cd nfc | ||
cordova platform add blackberry10 | ||
cordova plugin add phonegap-nfc | ||
cordova plugin add cordova-plugin-bb-invoke | ||
|
||
edit `www/js/index.js` and replace `onDeviceReady` with | ||
|
||
onDeviceReady: function() { | ||
app.receivedEvent('deviceready'); | ||
|
||
// Read NDEF formatted NFC Tags | ||
nfc.addNdefListener ( | ||
function (nfcEvent) { | ||
var tag = nfcEvent.tag, | ||
ndefMessage = tag.ndefMessage; | ||
|
||
// dump the raw json of the message | ||
// note: real code will need to decode | ||
// the payload from each record | ||
alert(JSON.stringify(ndefMessage)); | ||
|
||
// assuming the first record in the message has | ||
// a payload that can be converted to a string. | ||
alert(nfc.bytesToString(ndefMessage[0].payload).substring(3)); | ||
}, | ||
function () { // success callback | ||
alert("Waiting for NDEF tag"); | ||
}, | ||
function (error) { // error callback | ||
alert("Error adding NDEF listener " + JSON.stringify(error)); | ||
} | ||
); | ||
}, | ||
|
||
Edit `config.xml` and `<rim:invoke-target>` just before `</widget>`. (See docs for more info about [invoke-target](https://github.com/chariotsolutions/phonegap-nfc#blackberry-10-invoke-target | ||
).) | ||
|
||
<rim:invoke-target id="your.unique.id.here"> | ||
<type>APPLICATION</type> | ||
<filter> | ||
<action>bb.action.OPEN</action> | ||
<mime-type>application/vnd.rim.nfc.ndef</mime-type> | ||
<!-- any TNF Empty(0), Well Known(1), MIME Media(2), Absolute URI(3), External(4) --> | ||
<property var="uris" value="ndef://0,ndef://1,ndef://2,ndef://3,ndef://4" /> | ||
</filter> | ||
</rim:invoke-target> | ||
|
||
Compile, install, and run | ||
|
||
cordova run | ||
|
||
 |