The @doordeck/headless-react-native-sdk is a lightweight React Native SDK built on top of the Doordeck SDK. This SDK provides a minimal interface for authentication and lock management, focusing on user-facing operations. It enables React Native applications to authenticate users, manage authentication tokens, retrieve lock details, and unlock devices via Doordeck's platform.
To install the SDK, ensure you have React Native set up in your project, then add the necessary dependencies:
npm install @doordeck/headless-react-native-sdkor using yarn:
yarn add @doordeck/headless-react-native-sdkImport every single method according to your usage
import { login } from '@doordeck/headless-react-native-sdk';
// ...
import { logout } from '@doordeck/headless-react-native-sdk';Logs the user in with their email and password.
Note: If login is performed without verification within the same session, authentication will only persist in runtime memory and will be lost when the app restarts.
import { login } from '@doordeck/headless-react-native-sdk';
login("user@example.com", "password123")
.then(response => console.log("Login successful", response))
.catch(error => console.error("Login failed", error));Sets an authentication token manually.
Note: Like login, authentication without verification will only persist in runtime memory and will be lost after the app restarts.
import { setAuthToken } from '@doordeck/headless-react-native-sdk';
setAuthToken("your-auth-token")
.then(response => console.log("Token set successfully", response))
.catch(error => console.error("Error setting token", error));Verifies an ephemeral key registration with a verification code. Upon successful verification, the user ID and authentication context are saved in persistent storage.
import { verify } from '@doordeck/headless-react-native-sdk';
verify("123456")
.then(() => console.log("Verification successful"))
.catch(error => console.error("Verification failed", error));Logs out the current user and clears the stored authentication context, including removing the persistent user ID.
import { logout } from '@doordeck/headless-react-native-sdk';
logout()
.then(() => console.log("Logged out"))
.catch(error => console.error("Logout failed", error));Retrieves a list of locks associated with a specific tile.
import { getLocksBelongingToTile } from '@doordeck/headless-react-native-sdk';
getLocksBelongingToTile("tile-uuid")
.then(response => console.log("Locks: ", response))
.catch(error => console.error("Failed to get locks", error));Unlocks a device given its lock ID.
import { unlockDevice } from '@doordeck/headless-react-native-sdk';
unlockDevice("lock-uuid")
.then(() => console.log("Device unlocked"))
.catch(error => console.error("Unlock failed", error));Each method returns a Promise. If an error occurs, the catch block will handle the failure, returning an error object containing an error code and message.
This SDK follows the Doordeck licensing agreement. Ensure compliance with Doordeck's API usage policies before integrating this SDK into your project.
For additional support, refer to the Doordeck Developer Documentation.