|
Posted by Visnu Priya on April 4th, 2012
We just finished creating an NFC capable app using Rhomobile and here is our blog about it. By the way this is second blog do encourage me to write more.
If you got some ideas (good crazy ones) on other usages, then please share it a comment so that we can develop it using RhoMobile under open source license. RhoMobile does support NFC capability, which includes:
You can also check the RhoMobile NFC documentation at http://docs.rhomobile.com/rhodes/nfc Let’s see how to develop NFC functionality based Rhodes application using Rhomobile. 1. Create sample rhodes app $ rhodes app sample_app $ cd sample_app $ rhodes model nfc 2. Enable NFC in build.yml android: version: 2.3.3 extensions: - nfc 3. In app/application.rb file, activate NFC on Android device.
def on_nfc_app
Rho::NFCManager.enable
Rho::NFCManager.set_nfc_callback("set_nfc_callback url")
Rho::NFCManager.set_nfc_tech_callback("nfc_tech_callback url")
Rho::NFCManager.perform_open_application_event
end
4. In app/Nfc/nfc_controller.rb
Rho::NFCManager.make_payload_with_well_known_text("en", "HELLO WORLD")
puts payload message into hash of records.Create hash of record Using Ndef (NFC data Exchange Format) as follows,
hash = {
'id' = [0],
'type' = Rho::NdefRecord:: RTD_TEXT,
'tnf' = Rho::NdefRecord::TNF_WELL_KNOWN,
'payload' = payload
}
Then use Rho::NFCManager.make_NdefRecord_from_hash(hash) method to create message record.Convert record array into message using following method record= Rho::NFCManager.make_NdefMessage_from_array_of_NdefRecord(records) Now we can push message using Rho::NFCManager.p2p_enable_foreground_nde_push(record) and when you want to stop message use Rho::NFCManager.p2p_disable_foreground_nde_push. Sample screenshots taken from Android Emulator: We hope you liked this blog. Unique Views: 1026 Total views: 1350 Follow responses at RSS 2.0. Leave a response | Trackback. 3 Responses to “Create NFC Apps Using RhoMobile”Leave a Reply |
Hi ,
Nice blog . could you please help me out regrading NFC , i m stuck in error ” No file found -NFCapp” while running example file which is provided in rhomobile website.
Regards,
Amyth
can you provide me the entire code pls….?
Hi, thanks for this blog, can you please do one about syncing and full CRUD using asynchttp instead of Rhosync or rhoconnect?