setProperty static method
- @Deprecated('This function is deprecated. Please use "setProperty" of "Countly.instance.userProfile" instead and do not forget to call "Countly.instance.userProfile.save"')
Set custom user property returns the error or success message
Implementation
@Deprecated('This function is deprecated. Please use "setProperty" of "Countly.instance.userProfile" instead and do not forget to call "Countly.instance.userProfile.save"')
static Future<String?> setProperty(String keyName, String keyValue) async {
if (!_instance._countlyState.isInitialized) {
String message = '"initWithConfig" must be called before "setProperty"';
log('setProperty, $message', logLevel: LogLevel.ERROR);
return message;
}
log('Calling "setProperty":[$keyName], value:[$keyValue]');
if (keyName.isEmpty) {
String error = 'setProperty, key cannot be empty';
log(error);
return 'Error : $error';
}
if (keyValue.isEmpty) {
String error = 'setProperty, value cannot be empty';
log(error);
return 'Error : $error';
}
List<String> args = [];
args.add(keyName);
args.add(keyValue);
final String? result = await _channel.invokeMethod('userData_setProperty', <String, dynamic>{'data': json.encode(args)});
return result;
}