setContactKey

Sets the contact key for the device’s user.

Syntax 

1MCReactModule.setContactKey(contactKey);

Parameters 

ParameterTypeDescription
contactKeystringThe value to be set as the contact key of the device’s user.

Returns 

  • void - No return value.

Example 

1import { MCReactModule } from "react-native-marketingcloudsdk";
2
3const setUserContactKey = () => {
4  try {
5    MCReactModule.setContactKey("user123@example.com");
6    console.log("Contact key set successfully");
7  } catch (error) {
8    console.error("Error setting contact key:", error);
9  }
10};

See Also 

Related Methods