WeatherKit SDK - daytimeForecast

92 Views Asked by At

I'm using WeatherKit SDK for history data fetching

To get data, I'm using next code:

do {
    let weather = try await WeatherDataSourceWeatherKit.weatherService.weather(
        for: location,
        including: .daily(startDate: date.startOfDay, endDate: date.endOfDay)
    )
    
    let weatherDays = weather.forecast.first!

    // Data handling
}

If I po received DayWeather object in console, it contains useful fields daytimeForecast and overnightForecast

Screenshot of DayWeather object's data

But when I try to access this data from the code, it's unavailable:

Screenshot of possible code suggestions #1Screenshot of possible code suggestions #2

Question: How I can get that daytimeForecast from object?

1

There are 1 best solutions below

0
Viktor On

At current day (Aug 12, 2023) daytimeForecast and overnightForecast values are not available through SDK due to API access limitations

According to documentation, it's available only via WeatherKit API: Apple documentation for DayPartForecast class. List of supported platforms contains only "WeatherKit API 1.0+" value

REST API response: Postman screenshot from WeatherKit API response. Response object contains mentioned "daytimeForecast" and "overnightForecast" objects

I've tried few ways to access it but no success. Feel free to suggest ways to overcome it or inform me when this data will be available in public API, so I can update the answer