# NFC Assignment

This guide explains how to manage NFC token assignments for EGYM accounts using the MMS API V2.

## Introduction

The fitness industry is adopting NFC technology for access control to facilities, equipment and other functions. This is driven by the demand for improved member experiences and operational efficiency.

We've introduced an API to manage NFC assignments to enable our customers to unlock EGYM and connected partner machines.

## Scenario

NFC pass is issued by a partner (e.g. MMS or customer's mobile app). Partner assigns an NFC token to the member's EGYM account so it could be used to log into EGYM machines.

## Preconditions

Partner provides the following information to EGYM

1. Pass Type ID for Apple Wallet NFC pass. Note that Apple Pass Type ID is issued per customer app that is managed by an Apple Developer account.
2. Collector ID and Key version for Google Wallet NFC pass.
3. NFC Pass payload examples for Apple and Google Wallets.
4. Private Key that is needed for EGYM machine to decrypt the NFC pass data that the phone sends.


One token per NFC Pass issuer
A member can have only one unique token per NFC Pass issuer. If a member uses two phones (iOS and Android), the NFC token must be the same for both.

## Detailed flow

1. Member creates NFC pass in the gym mobile app
2. Partner back-end assigns NFC pass token to member's EGYM account via MMS API
3. Member comes to EGYM Machine and taps with the phone to login
4. EGYM Machine shouts: *"Any `pass.com.partner` passes here?"*
5. Phone finds the pass: *"Yes, I have one!"*
6. Phone takes NFC message and encrypts it using the **Public Key** inside the pass, and sends it to the machine
7. EGYM Machine uses **Private Key** to decrypt the message
8. EGYM Machine looks up the EGYM account that is associated with the given token and NFC pass issuer


## Assign NFC

## Get NFC

Retrieve the member account by NFC token.

## Retrieve Account NFC Token

Retrieve the NFC token assigned to a member account.

## Delete NFC

Remove the NFC token assignment from a member account.