setAttribute

Sets the value of an attribute in the registration.

Syntax 

1MCReactModule.setAttribute(key, value);

Parameters 

ParameterTypeDescription
keystringThe name of the attribute to be set in the registration.
valuestringThe value of the key attribute to be set in the registration.

Returns 

  • void - No return value.

Example 

1import { MCReactModule } from "react-native-marketingcloudsdk";
2
3const setUserAttribute = () => {
4  try {
5    MCReactModule.setAttribute("userType", "premium");
6    MCReactModule.setAttribute("lastLogin", new Date().toISOString());
7    console.log("Attributes set successfully");
8  } catch (error) {
9    console.error("Error setting attribute:", error);
10  }
11};

See Also 

Related Methods