/nfc-launch

Demo - launch a Cordova app when scanning a NFC tag

Primary LanguageJava

NFC Launch

Launch a Cordova app by scanning a NFC tag.

Uses phonegap-nfc.

Create Sample NFC Tag

Use NFC Tag Writer to create a NFC tag with the following data

Details

  • Launch NFC Tag Writer
  • Choose Write tags
  • Choose New dataset
  • Choose Link
  • Enter http://example.com/foo in the Website field
  • Do not enter anything in the optional title field.

Intent Filter

The intent filter is defined in AndroidManifest.xml

<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:host="example.com" android:pathPrefix="" android:scheme="http" />
</intent-filter>

Compile and Run

Build and deploy to an Android phone using Cordova 5.0.0

cordova run --device

While the app is running, Scan an NFC tag to ensure foreground dispatch works.

Close the app

Scan the NFC tag you created. The app will launch and display the tag info.