setUserProperty static method

Future<void> setUserProperty({
  1. required ApphudUserPropertyKey key,
  2. dynamic value,
  3. bool setOnce = false,
})

Set custom user property. Value must be one of: int, float, bool, String, null. Example:

// use built-in property key
Apphud.setUserProperty(key: ApphudUserPropertyKey.email, value: 'user4@example.com', setOnce: true)
// use custom property key
Apphud.setUserProperty(key: ApphudUserPropertyKey.customProperty('custom_test_property_1'), value: 0.5)

You can use several built-in keys with their value types: ApphudUserPropertyKey.email: User email. Value must be String. ApphudUserPropertyKey.name: User name. Value must be String. ApphudUserPropertyKey.phone: User phone number. Value must be String. ApphudUserPropertyKey.age: User age. Value must be Int. ApphudUserPropertyKey.gender: User gender. Value must be one of: 'male', 'female', 'other'. ApphudUserPropertyKey.cohort: User install cohort. Value must be String.

  • parameter key is required. Initialize class with custom string or using built-in keys. See example above.
  • parameter value is required/optional. Pass null to remove given property from Apphud.
  • parameter setOnce is optional. Pass true to make this property non-updatable.

Implementation

/// Example:
/// ```dart
/// // use built-in property key
/// Apphud.setUserProperty(key: ApphudUserPropertyKey.email, value: 'user4@example.com', setOnce: true)
/// // use custom property key
/// Apphud.setUserProperty(key: ApphudUserPropertyKey.customProperty('custom_test_property_1'), value: 0.5)
/// ```
///
/// You can use several built-in keys with their value types:
/// `ApphudUserPropertyKey.email`: User email. Value must be String.
/// `ApphudUserPropertyKey.name`: User name. Value must be String.
/// `ApphudUserPropertyKey.phone`: User phone number. Value must be String.
/// `ApphudUserPropertyKey.age`: User age. Value must be Int.
/// `ApphudUserPropertyKey.gender`: User gender. Value must be one of: 'male', 'female', 'other'.
/// `ApphudUserPropertyKey.cohort`: User install cohort. Value must be String.
///
/// - parameter [key] is required. Initialize class with custom string or using built-in keys. See example above.
/// - parameter [value] is required/optional. Pass `null` to remove given property from Apphud.
/// - parameter [setOnce] is optional. Pass `true` to make this property non-updatable.
static Future<void> setUserProperty({
  required ApphudUserPropertyKey key,
  dynamic value,
  bool setOnce = false,
}) =>
    _channel.invokeMethod(
      'setUserProperty',
      {
        'key': key.keyName,
        'value': value,
        'setOnce': setOnce,
      },
    );