---
title: "invalidate(errorMessage:)"
framework: corenfc
role: symbol
role_heading: Instance Method
path: "corenfc/nfcreadersessionprotocol/invalidate(errormessage:)"
---

# invalidate(errorMessage:)

Closes the reader session and displays an error message to the user.

## Declaration

```swift
func invalidate(errorMessage: String)
```

## Parameters

- `errorMessage`: The error message to display.

## Discussion

Discussion Use this method to end the reader session and display a message to the user when an error condition occurs after the app successfully reads a tag. This type of error can occur if, for example, the app reads data from an NFC tag, but determines that the data has expired and discards it. The app then calls invalidate(errorMessage:) to end the reader session, and to let the user know why it discarded the data. note: After invalidating a reader session, you cannot use it to scan and detect other tags.

## See Also

### Managing a Reader Session

- [begin()](corenfc/nfcreadersessionprotocol/begin().md)
- [invalidate()](corenfc/nfcreadersessionprotocol/invalidate().md)
- [alertMessage](corenfc/nfcreadersessionprotocol/alertmessage.md)
- [begin()](corenfc/nfcreadersessionprotocol/begin().md)
- [invalidate()](corenfc/nfcreadersessionprotocol/invalidate().md)
- [alertMessage](corenfc/nfcreadersessionprotocol/alertmessage.md)
