NFC Plugin
Read NFC tags natively in your iOS WebView app and pass tag data to your web app.
Near-Field Communication (NFC) technology is one of the latest technologies that has become very popular among mobile users. It enables two devices or a device and an NFC tag to communicate wirelessly when in close proximity. NFC is widely used on iOS devices for reading and writing small amounts of data, making it an effective tool for sharing information via NFC-enabled cards or tags.
The NFC API allows developers to read and write data to NFC tags directly from app code. This opens up new ways for apps to interact with users, from sharing contact information to embedding text snippets.
WebViewGold NFC Plugin Integration
While NFC is not part of the general WebViewGold feature scope, we offer a custom, easy WebViewGold NFC plugin integration (via JavaScript) on an individual basis.
Please send us your requirements (e.g., writing/reading text snippets and/or contact card details to/from NFC tags) via an email to [email protected] for a free consultation and a non-binding quote.
Writing
To write a value to an NFC tag, send a command from your web app by loading the following URL: writenfc://?value=data
Example:<a href="writenfc://?value=WebViewGold.com"> Write to an NFC tag </a>
This puts your app into Write Mode and stores the value until a tag is scanned.
Writing to a VCARD
Use the same API as writing plaintext. Format the text like:
VCARDSeparate properties with an underscore (
FN:John Doe
Title:Developer
TEL;TYPE=CELL:0452641211
_
_
_
_) and prefix the text with VCARD_. See https://en.wikipedia.org/wiki/VCard#Properties for a list of supported properties.
Reading
To read an NFC tag, load readnfc://. The app will return the information to your web app by calling readNFCResult(data, id, tag) where data is the stored value, id the tag identifier and tag the tag type. Define this JavaScript function in your web app to handle the values.
How to Test the API
- Open the Config file of your app’s codebase.
- Enter your purchase code.
- Set the app’s URL to the NFC API Test Page: https://webviewgoldtest.github.io/NFCtesting.html
- Run the app.
- Press one of the Read or Write options to enable the corresponding mode. If writing, enter a value.
- Bring the NFC tag to the device to complete the read or write operation. The test page and app will display the results.