getDeviceId

Returns the deviceId used by Engagement to send push messages to the device.

Syntax

MCReactModule.getDeviceId() ⇒ Promise.<string?>

Returns

  • Promise.<string?> - A promise to the device ID.

Example

import { MCReactModule } from "react-native-marketingcloudsdk";

const getCurrentDeviceId = async () => {
  try {
    const deviceId = await MCReactModule.getDeviceId();
    if (deviceId) {
      console.log("Device ID:", deviceId);
    } else {
      console.log("No device ID available");
    }
  } catch (error) {
    console.error("Error getting device ID:", error);
  }
};

See Also