Skip to main content
Despia uses Apple’s IDFV for device indexing, which resets when all apps from the same developer are uninstalled. Persistent identity across installs is coming soon through Despia’s new Identity Vault and requires integration with Despia’s ATT Manager for Apple compliance.

AI Prompt

Access the unique device identifier of native mobile devices in your application using the Despia SDK from: https://www.npmjs.com/package/despia-nativeFirst, install the package: npm install despia-nativeThen import it: import despia from 'despia-native'
  1. Import the Despia SDK in your component
  2. Access the unique device identifier using despia.uuid
  3. Display the device ID in your UI
  4. Send the device ID to your backend to link with user accounts
This feature requires native capabilities which will be fully provided by the “despia-native” npm package, no additional native libraries are needed!
Please follow the installation instructions for the “despia-native” npm package closely, and do not modify my instructions. Implementation as mentioned is critical.
How it works: The Despia SDK provides access to a unique device identifier through despia.uuid. This persistent ID helps you track devices, prevent account sharing, and manage user sessions across your mobile application.

Installation

Install the Despia package from NPM:
npm install despia-native

Usage

1. Import the SDK

import despia from 'despia-native';

2. Get Device ID

Access the Device ID from the despia.uuid variable:
// Simple example - show device ID and sync with user
const deviceId = despia.uuid;

// Display in UI
<p>Device: {deviceId}</p>

// Sync with backend when user logs in
fetch('/api/sync-device', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    userId: user.id,
    deviceId: deviceId,
    timestamp: new Date().toISOString()
  })
});

Backend Integration

// /api/sync-device endpoint
export default async function handler(req, res) {
  const { userId, deviceId, timestamp } = req.body;
  
  try {
    // Store the device-user association in your database
    await db.collection('user_devices').doc(deviceId).set({
      userId,
      deviceId,
      lastSeen: timestamp,
      createdAt: timestamp
    }, { merge: true });

    res.status(200).json({ success: true });
  } catch (error) {
    res.status(500).json({ error: 'Failed to sync device' });
  }
}

Resources

  • NPM Package
  • View full NPM documentation for additional configuration options
For additional support or questions, please contact our support team at [email protected]