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