setAttribute

Sets a custom attribute for the device.

Syntax

Future<void> setAttribute(String key, Object? value)

Parameters

  • key (String) - The attribute key
  • value (Object?) - The attribute value

Returns

  • Future<void> - Completes when the attribute has been set.

Example

try {
  await SfmcSdk.setAttribute('userType', 'premium');
  await SfmcSdk.setAttribute('lastLogin', DateTime.now().toIso8601String());
  print('Attributes set successfully');
} catch (e) {
  print('Failed to set attribute: $e');
}

Related Methods