getContactKey

Returns the contact key currently set on the device.

Syntax 

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

Returns 

  • Promise.<string?> - A promise to the current contact key.

Example 

1import { MCReactModule } from "react-native-marketingcloudsdk";
2
3const getCurrentContactKey = async () => {
4  try {
5    const contactKey = await MCReactModule.getContactKey();
6    if (contactKey) {
7      console.log("Current contact key:", contactKey);
8    } else {
9      console.log("No contact key set");
10    }
11  } catch (error) {
12    console.error("Error getting contact key:", error);
13  }
14};

See Also 

Related Methods