setLocation static method

  1. @Deprecated('This functions is deprecated, please use "setUserLocation" instead')
Future<String?> setLocation(
  1. String latitude,
  2. String longitude
)

set the user location. returns the error or success message

Implementation

@Deprecated('This functions is deprecated, please use "setUserLocation" instead')
static Future<String?> setLocation(String latitude, String longitude) async {
  if (!_instance._countlyState.isInitialized) {
    String message = '"initWithConfig" must be called before "setLocation"';
    log('setLocation, $message', logLevel: LogLevel.ERROR);
    return message;
  }
  log('Calling "setLocation" with latitude:[$latitude], longitude:[$longitude]');
  log('setLocation is deprecated, use setUserLocation instead', logLevel: LogLevel.WARNING);
  if (latitude.isEmpty) {
    String error = 'setLocation, latitude cannot be empty';
    log(error);
    return 'Error : $error';
  }
  if (longitude.isEmpty) {
    String error = 'setLocation, longitude cannot be empty';
    log(error);
    return 'Error : $error';
  }
  final String? result = await setUserLocation(gpsCoordinates: '$latitude,$longitude');
  return result;
}