Skip to content

NFC login

You can benefit of nfc to login. As a short range wireless communication, it prevents remote user from spying on your communication. The main benefit is that exchange of encryption key is safer that with BLE or WiFi.


You can configure your tap with IoTize Studio to use device a user that will be automatically logged when using NFC and encryption.

The sample below show you how to view the nfc auto logging profile configured on your tap:

import { Tap } from '@iotize/device-client.js/device';

let tap: Tap; // ... init your tap

let autoLogProfileId = (
  await tap.service.interface.getNfcAutologProfileId()

if (autoLogProfileId != 0) {
  let autoLogProfileName = (
  console.log(`NFC Auto login with profile: ${autoLogProfileName}`);
} else {
  console.log(`NFC Auto login is disabled`);

Login with nfc

The sample below show you how to log in thanks to NFC and then switch the communication protocol to BLE once communication encryption setup is done.

import { Tap, SessionState } from '@iotize/device-client.js/device';
import { ComProtocol } from '@iotize/device-client.js/protocol/api';

let nfcProtocol: any;

let tap = Tap.fromProtocol(nfcProtocol);
// Connect with nfc
await tap.connect();
// Activate encryption while we are in NFC
await tap.encryption(true);

let sessionState: SessionState = await tap.refreshSessionState();
console.log(`Session state: `, sessionState);

// now, your requests are encrypted. You can switch to long range protocol such as WiFi or BLE
let myOtherProtoocol: ComProtocol; // Your long range protocol

await tap.connect();