Weather Warning City List

Platform: API iOS Android

Get a list of cities for the specified country or region where weather warnings are currently in effect.

See also Weather warning iOS SDK to get warning details.

Note: Weather Warning City List only supports China (including Hong Kong, Macao and China Taiwan) now. For other countries and regions, please use Weather Warning.

Tips: For more warning description, see Resource - Warning Info.

Interface code Interface Class
warningList List of warning cities WarningListResponse

Parameters

WarningListParameter

  • range(required)Set country or region, ISO 3166 format, example: range=cn or range=hk. Currently this function only supports city list in China (including Hong Kong, Macao and China Taiwan), for other countries and regions please use Weather Warning to get it separately.

Sample code

Swift

Task{
    do {
        let parameter = WarningListParameter(range: .CN)
        let response = try await QWeather.instance
            .warningList(parameter)
        print(response)
    } catch QWeatherError.errorResponse(let error) {
        print(error)
    } catch {
        print(error)
    }
}

Objective-C

WarningListParameter *parameter = [WarningListParameter instanceWithRange:RangeCN];
[QWeatherObjc warningList:parameter completionHandler:^(WarningListResponse * _Nullable response, NSError * _Nullable error) {
    if (response) {
        NSLog(@"%@", response.description);
    }
    if (error) {
        NSLog(@"%@", error.localizedDescription);
    }
}];

Response

WarningListResponse

  • code See Status Code
  • updateTime API last update time
  • warningLocList.locationId List of Location ID for warning
  • refer.sources Data source and other statements, may be null
  • refer.license Data license, may be null