getDeviceId

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

Syntax 

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

Returns 

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

Example 

1import { MCReactModule } from "react-native-marketingcloudsdk";
2
3const getCurrentDeviceId = async () => {
4  try {
5    const deviceId = await MCReactModule.getDeviceId();
6    if (deviceId) {
7      console.log("Device ID:", deviceId);
8    } else {
9      console.log("No device ID available");
10    }
11  } catch (error) {
12    console.error("Error getting device ID:", error);
13  }
14};

See Also