08-14-2012 01:24 AM - edited 08-14-2012 01:34 AM
Hello Everyone.
Currently I am testing some Apps On my BlackBerry 10 Dev Alpha.
My Question Is: Are there some ways to Invoke NFC APIs in BlackBerry 10 Webworks(HTML5) Platform?
Such as Reading Tags or Writing Tags.
Higly Appreciated if anyone can help me.~~~
08-14-2012 02:06 AM
Read and Write NFC APIs are missing so far in WebWorks, but with the help of an Native-to-WebWorks extension you are able to make it working. For WebWorks extensions in BB10 have a closer look at this thread I reported about an example already available on github and how to get it running right now with a small fix: http://supportforums.blackberry.com/t5/Web-and-Web
Then there is the possibility to set up an app to be invoked when NFC tags are recognized by BB10 device. You could try the invokable example here: https://github.com/blackberry/BB10-WebWorks-Sample
You need to change the config.xml to be invoked on NFC tags by adding this:
<rim:invoke-target id="example.NFCInvokable.app"> <type>APPLICATION</type> <filter> <action>bb.action.OPEN</action> <mime-type>application/vnd.rim.nfc.ndef.1.Sp</mime-type> <mime-type>application/vnd.rim.nfc.ndef.1.T</mime- type> <mime-type>application/vnd.rim.nfc.ndef.1.U</mime- type> <mime-type>application/vnd.rim.nfc.ndef.4</mime-ty pe> </filter> </rim:invoke-target>
To read and write NFC, for now, there is an example written in Cascades: https://github.com/blackberry/Cascades-Community-S
08-15-2012 12:04 AM
Is there an example of Reading tags through Webworks Extensions? Thank U
08-15-2012 12:40 AM
No. there isn't since there is not API to read and write NFC tags yet. Thats why I pointed out the invoker example. With the help of the invoker your app is opended when your device is reading NFC tags and is pointing ot it with the following data example:
action: "bb.action.OPEN" background: "no" data: "0QEaVAJlbkhlbGxvLCBJIGFtIGFuIE5GQyB0YWch" target: "my.app" type: "application/vnd.rim.nfc.ndef.1.T"
So you get the "type" of the tag and the "data" written to it and can build something to read tags without waiting for the API or writing your own extension.