getContactKey

Returns the contact key currently set on the device.

Syntax

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

Returns

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

Example

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

const getCurrentContactKey = async () => {
  try {
    const contactKey = await MCReactModule.getContactKey();
    if (contactKey) {
      console.log("Current contact key:", contactKey);
    } else {
      console.log("No contact key set");
    }
  } catch (error) {
    console.error("Error getting contact key:", error);
  }
};

See Also