|
| 1 | +--- |
| 2 | +title: ReadNFC function | Microsoft Docs |
| 3 | +description: Reference information, including syntax, for the ReadNFC function in Power Apps |
| 4 | +author: gregli-msft |
| 5 | +manager: kvivek |
| 6 | +ms.service: powerapps |
| 7 | +ms.topic: reference |
| 8 | +ms.custom: canvas |
| 9 | +ms.reviewer: nabuthuk |
| 10 | +ms.date: 06/16/2021 |
| 11 | +ms.author: gregli |
| 12 | +search.audienceType: |
| 13 | + - maker |
| 14 | +search.app: |
| 15 | + - PowerApps |
| 16 | +--- |
| 17 | +# ReadNFC function in Power Apps |
| 18 | + |
| 19 | +Reads a Near Field Communication (NFC) tag. |
| 20 | + |
| 21 | +## Description |
| 22 | + |
| 23 | +Use **ReadNFC** function to read an NFC tag that is close to your device. When invoked, the screen displays instructions for scanning an NFC tag, and only returns after the tag has been scanned or a timeout expires. |
| 24 | + |
| 25 | +**ReadNFC** returns a record of information about the tag that has been read. The record contains: |
| 26 | + |
| 27 | +| Column | Type | Description | |
| 28 | +|----|----|----| |
| 29 | +| **RTD** | Text | The tag's Record Type Definition (RTD). Only *RTD_TEXT* and *RTD_URI* are supported at this time. | |
| 30 | +| **TNF** | Number | The tag's Type Name Format (TNF). Only *TNF_WELL_KNOWN* is supported at this time. | |
| 31 | +| **Text** | Text | The text payload of the NFC tag if RTD is *RTD_TEXT*, *blank* otherwise. | |
| 32 | +| **URI** | Hyperlink | The URI payload of the NFC tag if RTD is *RTD_URI*, *blank* otherwise. | |
| 33 | + |
| 34 | +If the tag is not supported, for example, the TNF is not *TNF_WELL_KNOWN*, or the scan timed out, then the record itself will be *blank* (and all the columns will be *blank* too). |
| 35 | + |
| 36 | +Always check the payload value for *blank* using the [**IsBlank**](function-isblank-isempty.md) function before using it. You do not need to check the **RTD** and **TNF** values yourself as they must be the correct values for **Text** and **URI** to have a non *blank* value. |
| 37 | + |
| 38 | +Additional **RTD** and **TNF** values may be supported in the future. If more values are supported, additional payload columns will also be added. The raw **RTD** and **TNF** values are provided for informational purposes. More information about these values and their use is available through the [NFC Forum](https://nfc-forum.org) and many other books and articles on NFC. |
| 39 | + |
| 40 | +If NFC is not supported on the device, a message will be shown to the user and the function will return a *blank* record. |
| 41 | + |
| 42 | +**ReadNFC** can only be used in [behavior formulas](../working-with-formulas-in-depth.md). |
| 43 | + |
| 44 | +## Syntax |
| 45 | + |
| 46 | +**ReadNFC**() |
| 47 | + |
| 48 | +## Examples |
| 49 | + |
| 50 | +Reads an NFC tag and displays the result. If the result is Text or URI, displays that value to the user. The [**With**](function-with.md) function is used to make the columns of the return record easily accessible. |
| 51 | + |
| 52 | +```powerapps-dot |
| 53 | +With( ReadNFC(), |
| 54 | + If( Not IsBlank( Text ), |
| 55 | + Notify( "Read Text: " & Text ), |
| 56 | + Not IsBlank( URI ), |
| 57 | + Notify( "Read URI: " & URI ), |
| 58 | + Notify( "Didn't read Text or URI" ) |
| 59 | + ) |
| 60 | +) |
| 61 | +``` |
| 62 | + |
| 63 | +Reads an NFC tag and displays type information about the result. |
| 64 | + |
| 65 | +```powerapps-dot |
| 66 | +With( ReadNFC(), Notify( "Tag TNF: " & TNF & ", RTD: " & RTD ) ) |
| 67 | +``` |
| 68 | + |
| 69 | +Collects read NFC tags for later use. |
| 70 | + |
| 71 | +```powerapps-dot |
| 72 | +Collect( ScannedTags, ReadNFC() ) |
| 73 | +``` |
| 74 | + |
| 75 | +[!INCLUDE[footer-include](../../../includes/footer-banner.md)] |
0 commit comments