Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Posts: 19
Registered: ‎02-14-2013
My Device: Red Z10
My Carrier: WIND Mobile
Accepted Solution

Peer to peer NFC - How to send multiple messages?

I am able to send one message from a device, and read it on the other.


I wanted to do a 3-way handshake using NFC, my goal was to have:
- App 1 writes a tag that starts app 2 on tap if it is not running
- App 2 sends a piece of data to app 1
- On reception app 1 sends another piece of data in response to app 2


To receive the data, I use a
- invoke-targe
- With a: <property var="uris" value="ndef://4/myApp.domain.com/action"/>
- Then I connect to InvokeManager::invoked, in which I extract the Payload


To send the data, I use
- nfc_create_ndef_record(NDEF_TNF_EXTERNAL
- nfc_push_ndef_message
- I use the nfc_target_t that I get in the NFC_SNEP_CONNECTION_EVENT event.


I am able to push the message immediately in NFC_SNEP_CONNECTION_EVENT, or later in an asynchronous event.
But I cannot push the message twice, else it is only received once


I didn't find a way to use the nfc_* native functions to read the NFC data. I am calling nfc_register_tag_readerwriter(TAG_TYPE_NDEF), but AbstractBpsEventHandler::event is never called

Martin Larochelle
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Peer to peer NFC - How to send multiple messages?

Hi Martin


unfortunately you cannot send multiple push messages in the context of a single NFC "tap". You need to have the users separate devices and tap again before you can send your second push message.


The alternative and arguably best way to implement your handshake is to use LLCP.


I'm working on a code sample for this right now and will publish asap.





Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim