setAttribute

Sets the value of an attribute in the registration.

Syntax

MCReactModule.setAttribute(key, value);

Parameters

Parameter Type Description
key string The name of the attribute to be set in the registration.
value string The value of the key attribute to be set in the registration.

Returns

  • void - No return value.

Example

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

const setUserAttribute = () => {
  try {
    MCReactModule.setAttribute("userType", "premium");
    MCReactModule.setAttribute("lastLogin", new Date().toISOString());
    console.log("Attributes set successfully");
  } catch (error) {
    console.error("Error setting attribute:", error);
  }
};

See Also