---
schema_version: "1"
id: 47618b17f18a4cb039d59f2fd5502b64893165769349bf4739a3f5ebc7de9d84
title: getDeviceId
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud-mobilepush/engagement_sdk/references/react/react_getDeviceId.md
canonical_url: https://developer.salesforce.com/docs/marketing/mobile-unified-sdk/references/engagement-mobile-sdk-reference/react_getDeviceId.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 6e32800f57a97b2602ace3cc1ebebb78be6a45902842526affd0e9a519f966eb
products:
  - Salesforce Engagement SDK
---
# getDeviceId

Returns the `deviceId` used by Engagement to send push messages to the device.

## Syntax

```javascript
MCReactModule.getDeviceId() ⇒ Promise.<string?>
```

## Returns

- `Promise.<string?>` - A promise to the device ID.

## Example

```javascript
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

- [Android SDK Reference](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/MarketingCloudSdk/8.0/-marketing%20-cloud%20-s-d-k/com.salesforce.marketingcloud.registration/-registration-manager/get-device-id.html)
- _SDK Reference for iOS_: [MarketingCloudSDK Module](https://developer.salesforce.com/docs/marketing/mobile-unified-sdk/references/ios-sdk-v11/mce-sdk/classes/marketingcloudsdk.md#deviceidentifier)
