setUserLocation static method

Future<String?> setUserLocation({
  1. String? countryCode,
  2. String? city,
  3. String? gpsCoordinates,
  4. String? ipAddress,
})

Set user location String country_code - ISO Country code for the user's country String city - Name of the user's city String gpsCoordinates - comma separate lat and lng values. For example, "56.42345,123.45325" String ipAddress - ip address All parameters are optional, but at least one has to be set

Implementation

static Future<String?> setUserLocation({String? countryCode, String? city, String? gpsCoordinates, String? ipAddress}) async {
  if (!_instance._countlyState.isInitialized) {
    String message = '"initWithConfig" must be called before "setUserLocation"';
    log('setUserLocation, $message', logLevel: LogLevel.ERROR);
    return message;
  }
  Map<String, String?> location = {};
  location['countryCode'] = countryCode;
  location['city'] = city;
  location['gpsCoordinates'] = gpsCoordinates;
  location['ipAddress'] = ipAddress;
  List<dynamic> args = [];
  args.add(location);
  final String? result = await _channel.invokeMethod('setUserLocation', <String, dynamic>{'data': json.encode(args)});
  return result;
}