Meet WeatherKit

RSS for tag

Discuss the WWDC22 Session Meet WeatherKit

Posts under wwdc2022-10003 tag

32 Posts

Post

Replies

Boosts

Views

Activity

Weather Kit is not returning historical data
I'm trying to get historical data using the following syntax: try await service.weather(for: location, including: .daily(startDate: past1, endDate: past2)) Where past1 and past2 are two dates in the past (I checked their format and they are correct). I always get the same result, namely the 10 days default forecast you usually get calling service.weather(for: location) Am I missing something?
4
3
2k
Oct ’23
WeatherKit Swift / REST mismatch? daytimeForecast and overnightForecast not available via Swift?
I am able to obtain daily forecasts via the REST API which include the daytimeForecast and overnightForecast records with their respective properties like cloudCover. So far I have failed to access them via the Swift API: forecast.daytimeForecast.cloudCover results in: "Value of type 'DayWeather' has no member 'daytimeForecast'". But if I print() the DayWeather objects, these members are actually printed with all their properties. Is there a way to get them I am overlooking?
2
0
2.0k
Jul ’23
Question on isDaylight
How is the IsDaylight value derived, and what factors are typically considered in its calculation? Specifically, is it determined based on the sunrise and sunset times, or are other factors considered? If it is based on sunrise and sunset times, is it based on Astronomical, Civil, and Nautical values? Are Weather and altitude considered as well? Thank you,
1
0
647
Apr ’23
WeatherKit stumbles under heavy load. And I don't understand Apple "support."
After Apple essentially shut down Dark Sky early (you can't trust it if it's off-line 8 hours a day 2/3 days), I've transitioned production traffic to WeatherKit. Generally slower (higher p50's, significantly higher p90s) Under bursts of traffic, it just chokes. Always. I have many users who have things set up to retrieve the weather on the hour (e.g., 6:00am). I have to have a failover weather source for these peaks, because weather kits just stops returning data under heavy load. It's not really acceptable that I'm paying significant $$$ for an API, and have to have another source for when the API predictably chokes. Dark Sky handled the load without breaking a sweat. Ever. I'm not sure what to do here. It's not an issue with the code, so there's no point in opening a code level support ticket. The feedback assistant refers you to the forums. General performance issues are not addressed by Apple engineers on the forums. So, the whole thing is a bit Kafkaesque. Is stumbling under load expected behavior? Does Apple have any performance expectations for the API? I've never dealt with an API provider that you couldn't get some sort of acknowledgement about issues. It's just weird.
1
3
1.2k
Mar ’23
WeatherKit REST authentication errors starting Sept 8th
Since September 8th, I've been unable to access the WeatherKit REST API due to authentication errors -- no changes on my side, but now I'm always getting responses like the following from the API: "status": 403, "error": "Forbidden", "message": "Access Denied", Has anyone else run into this problem in the last few days, and/or know how to work around it? The only place I've seen other report reporting so far is here: https://twitter.com/keff85/status/1569054904655773696 I tried upgrading to a paid WeatherKit plan (the lowest level is $50/month) but that doesn't seem to have helped. I believe WeatherKit Swift is working fine, but WeatherKit REST seems to be down -- or perhaps the auth changed somehow without warning?
6
1
2.5k
Mar ’23
WeatherKit REST API Authentication
Hi there! Please could you publish some of the specifics for authentication for the new WeatherKit REST API? I am attempting to use something cobbled together from MapKit, and unfortunately WeatherKit returns a 500 error in response. Broken code sample below. If you find a working solution or can identify an error, please comment with the solution. Thank you! require 'http' require 'jwt' require 'openssl' require 'logger' p8 = OpenSSL::PKey::EC.new(File.read("/PATH/TO/DOWNLOADED/P8/FILE")) token = JWT.encode({ iss: 'KEY_NAME_FROM_CIP', iat: Time.now.to_i, exp: Time.now.to_i + 3600, aud: 'weatherkit', }, p8, 'ES256', { kid: 'KEY_ID_FROM_CIP', typ: 'JWT' }) res = HTTP.use(logging: { logger: Logger.new(STDOUT) }).headers( "Authorization" => "Bearer #{token}" ).get "https://weatherkit.apple.com/api/v1/weather/en/LONG/LAT?dataSets=currentWeather&timezone=Europe/London" puts "code: #{res.code}" puts res.body
20
7
9.8k
Mar ’23
Getting WeatherKit error WeatherDaemon.WDSJWTAuthenticatorService.Errors
I am looking into the possibility of adding WeatherKit support to one of my apps. I have added the WeatherKit capability to my app and can see it up in the App ID configuration, the bundle ID is marked as explicit. I waited overnight just in case, but I keep just getting the following error when I run on a real device: Error Domain=WeatherDaemon.WDSJWTAuthenticatorService.Errors Code=1 "(null)" This app has been in the store for years, so I know the rest of the configuration should be fine. What am I missing?
6
0
6.1k
Mar ’23
WeatherKit - iPad Swift Playgrounds Script
Insights & assistance would be greatly appreciated. Have a paid/current developers account which shows WeatherKit as being available/having 500,000 calls available, but I have not sorted out settings for ‘certificates, identifiers, and profiles’. Am attempting to use an iPad Pro with iOS 16 to run the following script using Swift Playgrounds Xcode Playground import WeatherKit import CoreLocation let weatherService = WeatherService() let Anchorage = CLLocation(latitude: 61, longitude: -149) let weather = try! await weatherService.weather(for: Anchorage) let temperature = weather.currentWeather.temperature print(temperature)  The error that I am seeing is: There was a problem running this playground. Please check your code and try again. There is no ‘red dot’ and technical guidance associated with resolving this error as one normally sees/experiences when working on scripts. Have exited/restarted Swift Playgrounds multiple times and still see this error. This error is unexpected, as I am usually able to create and run swift scripts on my iPad.
1
0
1.8k
Jan ’23
weatherKit
Hey everyone, I am working on a weather app using weatherKit on SwiftUI and I have everything set up such as the current weather, ten-day and hourly forecast. My only question is that I want to have the feature to search for a city that I want to add and see the weather information for a specific Country/city. How do I add an autocomplete search field. Is it possible to do it using weatherKit? Or its something completely different thing that I need to add. Thank you.
1
0
1.5k
Nov ’22
MinuteWeather summary property returns empty string
I've been unable to get MinuteWeather to return anything for the summary property -- it used to return a nil value which was fixed in a previous beta, but now it always returns an empty string. The rest of the MinuteWeather data returns as expected. Example call: let latitude = 37.323 let longitude = -122.032 Task { let weatherData = WeatherData.shared     let minutely = await weatherData.minutelyForecast(for: CLLocation(latitude: latitude, longitude: longitude))          guard let minutelyWeather = minutely else {       print("WeatherKit minutely data unavailable")       return }     print(minutelyWeather.summary) // This returns "" } WeatherData class: class WeatherData: NSObject { static let shared = WeatherData() private let service = WeatherService.shared func minutelyForecast(for location: CLLocation) async -> WeatherKit.Forecast<MinuteWeather>? { let minuteWeather = await Task.detached(priority: .userInitiated) { let forecast = try? await self.service.weather(for: location, including: .minute) return forecast }.value return minuteWeather } }
3
1
1.2k
Oct ’22
WeatherQueries with start/end dates not returning forecast for those dates
try await WeatherService.shared.weather(for: sf, including: .daily(startDate: start, endDate: end)) If the start date is in the past I get an empty forecast. If start date is in the future I just get the current day's forecast. I tried with .hourly as well; got the same problem as I always get hourly data for the current day.
3
3
1.6k
Sep ’22
How to Fetch SunEvents?
Hello, I'm quite new to SwiftUI Development, learned how to code without getting a Compute Science college Degree. Please advise how do I fetch SunEvents? private func showWeatherInformation(latitude: Double, longtitude: Double) async {         let weatherService = WeatherService()         let journalingWeather = CLLocation(latitude: latitude, longitude: longtitude)                  do {             let weather = try await weatherService.weather(for: journalingWeather)             let temperature = weather.currentWeather.temperature.value.description             let humidity = weather.currentWeather.humidity.formatted(.percent).description             let weatherDesc = weather.currentWeather.condition.description             let weatherIcon = weather.currentWeather.symbolName.description             let feltLikeTemp = weather.currentWeather.apparentTemperature.value.description             let pressure = weather.currentWeather.pressure.value.description             let dewPoint = weather.currentWeather.dewPoint.value.description             let uvIndex = weather.currentWeather.uvIndex.value.description             let visibility = round(weather.currentWeather.visibility.value).description             let windSpeed = weather.currentWeather.wind.speed.value.description             let compass = weather.currentWeather.wind.direction.value.description                          /// What to decode?             let sunEvents = try SunEvents(from: journalingWeather as! Decoder)             let sunrise = sunEvents.sunrise ?? Date.now             let sunset = sunEvents.sunset ?? Date.now                          self.temperatureInput = temperature             self.weatherDescriptionInput = weatherDesc             self.weatherIconInput = weatherIcon             self.feltLikeTemperatureInput = feltLikeTemp             self.pressureInput = pressure             self.humidityInput = humidity             self.dewPointInput = dewPoint             self.uvIndexInput = uvIndex             self.visibilityInput = visibility             self.windSpeedInput = windSpeed             self.windDegreeInput = compass             self.sunriseTimeInput = sunrise             self.sunsetTimeInput = sunset         } catch {             print("\(error)")         }     } I'm getting this error Thread 1: signal SIGABRT at let sunEvents = try SunEvents(from: journalingWeather as! Decoder) when I run it on actual device. Any help would be very much appreciated. Thank you!
3
0
2.1k
Aug ’22
MinuteWeather always returns nil
Has anyone else been able to retrieve weather data from MinuteWeather? Specifically, I'm looking to access summary, but MinuteWeather always returns nil and the WeatherAvailability check for it returns unsupported. I know it's not location based since I'm testing with the same locations I've used previously with the Dark Sky API (where minutely was available). Example call: let latitude = 37.323 let longitude = 122.032 Task { let weatherData = WeatherData.shared     let minutely = await weatherData.minutelyForecast(for: CLLocation(latitude: latitude, longitude: longitude))          guard let minutelyWeather = minutely else {       print("WeatherKit minutely data unavailable")       return }     // ... } WeatherData class: class WeatherData: NSObject { static let shared = WeatherData() private let service = WeatherService.shared func minutelyForecast(for location: CLLocation) async -> WeatherKit.Forecast<MinuteWeather>? { let minuteWeather = await Task.detached(priority: .userInitiated) { let forecast = try? await self.service.weather(for: location, including: .minute) return forecast }.value return minuteWeather } }
1
1
1k
Jul ’22
Does anyone's WeatherKit work on a real device?
I'm working on an app with WeatherKit. The app works on the simulator, but it doesn't work on the real device. Calling "weatherService.weather(for: ..." never returns data or an error. do { let weather = try await weatherService.weather(for: myPlace) print(weather) // always on the simulator, never on the device     } catch { // never gets a call    print(error) } I'm using the latest beta on my device. Apple's TestFlight sample app doesn't work on the device, but it works fine on the simulator. Does anyone's WeatherKit work on a real device?
2
0
1.5k
Jul ’22
WeatherKit iOS SDK 401 network error
I'm following along to the WWDC WeatherKit session, and I keep getting this 401 network error that causes my app to crash on a fatal error. I have already created the proper Bundle App ID with WeatherKit enabled, and added the WeatherKit capability. Here is my code: private func getWeather() async -> Double {         let weatherService = WeatherService()         let syracuse = CLLocation(latitude: 33.6846, longitude: 117.8265)         let weather = try! await weatherService.weather(for: syracuse)         let temperature = weather.currentWeather.temperature         return temperature.converted(to: .celsius).value     } Full error message: 2022-06-07 17:35:43.051776-0700 WWDC2022[56529:1296409] WWDC2022/WeatherView.swift:30: Fatal error: 'try!' expression unexpectedly raised an error: WeatherDaemon.WDSHMACJWTAuthenticatorService.Errors.invalidJWTResponse(Optional(<NSHTTPURLResponse: 0x6000018402c0> { URL: https://weather-data.apple.com/v2/token } { Status Code: 401, Headers {     Connection =     (         close     );     "Content-Length" =     (         0     );     Date =     (         "Wed, 08 Jun 2022 00:35:43 GMT"     );     Server =     (         Apple     );     "Strict-Transport-Security" =     (         "max-age=31536000; includeSubdomains"     );     "X-Apple-Origin" =     (         "8961098f-b238-3714-ba44-5b569c861456"     );     "X-Cache" =     (         "TCP_MISS from a23-219-38-54.deploy.akamaitechnologies.com (AkamaiGHost/10.8.2-41841244) (-)"     );     "X-Content-Type-Options" =     (         nosniff     );     "X-Frame-Options" =     (         SAMEORIGIN     );     "X-REQUEST-ID" =     (         "5156c5c7-d23b-4a66-a161-c8a9fb849c85"     );     "X-XSS-Protection" =     (         "1; mode=block"     ); } }))
26
10
7.7k
Jul ’22
Weather Kit is not returning historical data
I'm trying to get historical data using the following syntax: try await service.weather(for: location, including: .daily(startDate: past1, endDate: past2)) Where past1 and past2 are two dates in the past (I checked their format and they are correct). I always get the same result, namely the 10 days default forecast you usually get calling service.weather(for: location) Am I missing something?
Replies
4
Boosts
3
Views
2k
Activity
Oct ’23
WeatherKit Swift / REST mismatch? daytimeForecast and overnightForecast not available via Swift?
I am able to obtain daily forecasts via the REST API which include the daytimeForecast and overnightForecast records with their respective properties like cloudCover. So far I have failed to access them via the Swift API: forecast.daytimeForecast.cloudCover results in: "Value of type 'DayWeather' has no member 'daytimeForecast'". But if I print() the DayWeather objects, these members are actually printed with all their properties. Is there a way to get them I am overlooking?
Replies
2
Boosts
0
Views
2.0k
Activity
Jul ’23
WeatherKit not showing Temp Correctly on device
Hi, I'm in the process of developing a weather app using WeatherKit. Everything seems to be working fine in the Simulator, but when I put it on the device (iPhone 13 Pro Max) the temperature displays wrong. Example: On Simulator: 34 F On Device: 34.98 F Anyone else have this problem? Dan Uff
Replies
2
Boosts
0
Views
1.5k
Activity
Jun ’23
Following "Meet WeatherKit"- getting async error
'async' call cannot occur in a global variable initializer for weather variable. import WeatherKit import CoreLocation let weatherService = WeatherService() let chicago = CLLocation(latitude: 47, longitude: 87.58293) let weather = try! await weatherService.weather(for: chicago) let temperature = weather.currentWeather.temperature
Replies
1
Boosts
0
Views
887
Activity
May ’23
Question on isDaylight
How is the IsDaylight value derived, and what factors are typically considered in its calculation? Specifically, is it determined based on the sunrise and sunset times, or are other factors considered? If it is based on sunrise and sunset times, is it based on Astronomical, Civil, and Nautical values? Are Weather and altitude considered as well? Thank you,
Replies
1
Boosts
0
Views
647
Activity
Apr ’23
WeatherKit stumbles under heavy load. And I don't understand Apple "support."
After Apple essentially shut down Dark Sky early (you can't trust it if it's off-line 8 hours a day 2/3 days), I've transitioned production traffic to WeatherKit. Generally slower (higher p50's, significantly higher p90s) Under bursts of traffic, it just chokes. Always. I have many users who have things set up to retrieve the weather on the hour (e.g., 6:00am). I have to have a failover weather source for these peaks, because weather kits just stops returning data under heavy load. It's not really acceptable that I'm paying significant $$$ for an API, and have to have another source for when the API predictably chokes. Dark Sky handled the load without breaking a sweat. Ever. I'm not sure what to do here. It's not an issue with the code, so there's no point in opening a code level support ticket. The feedback assistant refers you to the forums. General performance issues are not addressed by Apple engineers on the forums. So, the whole thing is a bit Kafkaesque. Is stumbling under load expected behavior? Does Apple have any performance expectations for the API? I've never dealt with an API provider that you couldn't get some sort of acknowledgement about issues. It's just weird.
Replies
1
Boosts
3
Views
1.2k
Activity
Mar ’23
WeatherKit REST authentication errors starting Sept 8th
Since September 8th, I've been unable to access the WeatherKit REST API due to authentication errors -- no changes on my side, but now I'm always getting responses like the following from the API: "status": 403, "error": "Forbidden", "message": "Access Denied", Has anyone else run into this problem in the last few days, and/or know how to work around it? The only place I've seen other report reporting so far is here: https://twitter.com/keff85/status/1569054904655773696 I tried upgrading to a paid WeatherKit plan (the lowest level is $50/month) but that doesn't seem to have helped. I believe WeatherKit Swift is working fine, but WeatherKit REST seems to be down -- or perhaps the auth changed somehow without warning?
Replies
6
Boosts
1
Views
2.5k
Activity
Mar ’23
WeatherKit REST API Authentication
Hi there! Please could you publish some of the specifics for authentication for the new WeatherKit REST API? I am attempting to use something cobbled together from MapKit, and unfortunately WeatherKit returns a 500 error in response. Broken code sample below. If you find a working solution or can identify an error, please comment with the solution. Thank you! require 'http' require 'jwt' require 'openssl' require 'logger' p8 = OpenSSL::PKey::EC.new(File.read("/PATH/TO/DOWNLOADED/P8/FILE")) token = JWT.encode({ iss: 'KEY_NAME_FROM_CIP', iat: Time.now.to_i, exp: Time.now.to_i + 3600, aud: 'weatherkit', }, p8, 'ES256', { kid: 'KEY_ID_FROM_CIP', typ: 'JWT' }) res = HTTP.use(logging: { logger: Logger.new(STDOUT) }).headers( "Authorization" => "Bearer #{token}" ).get "https://weatherkit.apple.com/api/v1/weather/en/LONG/LAT?dataSets=currentWeather&timezone=Europe/London" puts "code: #{res.code}" puts res.body
Replies
20
Boosts
7
Views
9.8k
Activity
Mar ’23
Getting WeatherKit error WeatherDaemon.WDSJWTAuthenticatorService.Errors
I am looking into the possibility of adding WeatherKit support to one of my apps. I have added the WeatherKit capability to my app and can see it up in the App ID configuration, the bundle ID is marked as explicit. I waited overnight just in case, but I keep just getting the following error when I run on a real device: Error Domain=WeatherDaemon.WDSJWTAuthenticatorService.Errors Code=1 "(null)" This app has been in the store for years, so I know the rest of the configuration should be fine. What am I missing?
Replies
6
Boosts
0
Views
6.1k
Activity
Mar ’23
Weatherkit Rest API getting unauthorized error
I have an app that submits a rest-api request to weatherkit for both currentWeather and weahtherForecast data. The app will error from time to time because of unauthorized request but what I don't understand is that it does not happen 100% of the time. Anyone encountered something similar?
Replies
11
Boosts
2
Views
2.7k
Activity
Mar ’23
WeatherKit - iPad Swift Playgrounds Script
Insights & assistance would be greatly appreciated. Have a paid/current developers account which shows WeatherKit as being available/having 500,000 calls available, but I have not sorted out settings for ‘certificates, identifiers, and profiles’. Am attempting to use an iPad Pro with iOS 16 to run the following script using Swift Playgrounds Xcode Playground import WeatherKit import CoreLocation let weatherService = WeatherService() let Anchorage = CLLocation(latitude: 61, longitude: -149) let weather = try! await weatherService.weather(for: Anchorage) let temperature = weather.currentWeather.temperature print(temperature)  The error that I am seeing is: There was a problem running this playground. Please check your code and try again. There is no ‘red dot’ and technical guidance associated with resolving this error as one normally sees/experiences when working on scripts. Have exited/restarted Swift Playgrounds multiple times and still see this error. This error is unexpected, as I am usually able to create and run swift scripts on my iPad.
Replies
1
Boosts
0
Views
1.8k
Activity
Jan ’23
weatherKit
Hey everyone, I am working on a weather app using weatherKit on SwiftUI and I have everything set up such as the current weather, ten-day and hourly forecast. My only question is that I want to have the feature to search for a city that I want to add and see the weather information for a specific Country/city. How do I add an autocomplete search field. Is it possible to do it using weatherKit? Or its something completely different thing that I need to add. Thank you.
Replies
1
Boosts
0
Views
1.5k
Activity
Nov ’22
MinuteWeather summary property returns empty string
I've been unable to get MinuteWeather to return anything for the summary property -- it used to return a nil value which was fixed in a previous beta, but now it always returns an empty string. The rest of the MinuteWeather data returns as expected. Example call: let latitude = 37.323 let longitude = -122.032 Task { let weatherData = WeatherData.shared     let minutely = await weatherData.minutelyForecast(for: CLLocation(latitude: latitude, longitude: longitude))          guard let minutelyWeather = minutely else {       print("WeatherKit minutely data unavailable")       return }     print(minutelyWeather.summary) // This returns "" } WeatherData class: class WeatherData: NSObject { static let shared = WeatherData() private let service = WeatherService.shared func minutelyForecast(for location: CLLocation) async -> WeatherKit.Forecast<MinuteWeather>? { let minuteWeather = await Task.detached(priority: .userInitiated) { let forecast = try? await self.service.weather(for: location, including: .minute) return forecast }.value return minuteWeather } }
Replies
3
Boosts
1
Views
1.2k
Activity
Oct ’22
WeatherQueries with start/end dates not returning forecast for those dates
try await WeatherService.shared.weather(for: sf, including: .daily(startDate: start, endDate: end)) If the start date is in the past I get an empty forecast. If start date is in the future I just get the current day's forecast. I tried with .hourly as well; got the same problem as I always get hourly data for the current day.
Replies
3
Boosts
3
Views
1.6k
Activity
Sep ’22
How to Fetch SunEvents?
Hello, I'm quite new to SwiftUI Development, learned how to code without getting a Compute Science college Degree. Please advise how do I fetch SunEvents? private func showWeatherInformation(latitude: Double, longtitude: Double) async {         let weatherService = WeatherService()         let journalingWeather = CLLocation(latitude: latitude, longitude: longtitude)                  do {             let weather = try await weatherService.weather(for: journalingWeather)             let temperature = weather.currentWeather.temperature.value.description             let humidity = weather.currentWeather.humidity.formatted(.percent).description             let weatherDesc = weather.currentWeather.condition.description             let weatherIcon = weather.currentWeather.symbolName.description             let feltLikeTemp = weather.currentWeather.apparentTemperature.value.description             let pressure = weather.currentWeather.pressure.value.description             let dewPoint = weather.currentWeather.dewPoint.value.description             let uvIndex = weather.currentWeather.uvIndex.value.description             let visibility = round(weather.currentWeather.visibility.value).description             let windSpeed = weather.currentWeather.wind.speed.value.description             let compass = weather.currentWeather.wind.direction.value.description                          /// What to decode?             let sunEvents = try SunEvents(from: journalingWeather as! Decoder)             let sunrise = sunEvents.sunrise ?? Date.now             let sunset = sunEvents.sunset ?? Date.now                          self.temperatureInput = temperature             self.weatherDescriptionInput = weatherDesc             self.weatherIconInput = weatherIcon             self.feltLikeTemperatureInput = feltLikeTemp             self.pressureInput = pressure             self.humidityInput = humidity             self.dewPointInput = dewPoint             self.uvIndexInput = uvIndex             self.visibilityInput = visibility             self.windSpeedInput = windSpeed             self.windDegreeInput = compass             self.sunriseTimeInput = sunrise             self.sunsetTimeInput = sunset         } catch {             print("\(error)")         }     } I'm getting this error Thread 1: signal SIGABRT at let sunEvents = try SunEvents(from: journalingWeather as! Decoder) when I run it on actual device. Any help would be very much appreciated. Thank you!
Replies
3
Boosts
0
Views
2.1k
Activity
Aug ’22
Apple Weather on Mac?
Hi, Will the Apple Weather framework work on Mac using SwiftUI? The documentation doesn't say MacOS. Thanks, Dan Uff
Replies
1
Boosts
0
Views
1.2k
Activity
Aug ’22
WeatherKit REST API access
Hi all, I am trying to use the WeatherKit REST API but when I try to register an app, I don't see WeatherKit as an available services that I can select under the App Services Tab. How do I get access to the WeatherKit service? Thanks,
Replies
3
Boosts
0
Views
1.8k
Activity
Aug ’22
MinuteWeather always returns nil
Has anyone else been able to retrieve weather data from MinuteWeather? Specifically, I'm looking to access summary, but MinuteWeather always returns nil and the WeatherAvailability check for it returns unsupported. I know it's not location based since I'm testing with the same locations I've used previously with the Dark Sky API (where minutely was available). Example call: let latitude = 37.323 let longitude = 122.032 Task { let weatherData = WeatherData.shared     let minutely = await weatherData.minutelyForecast(for: CLLocation(latitude: latitude, longitude: longitude))          guard let minutelyWeather = minutely else {       print("WeatherKit minutely data unavailable")       return }     // ... } WeatherData class: class WeatherData: NSObject { static let shared = WeatherData() private let service = WeatherService.shared func minutelyForecast(for location: CLLocation) async -> WeatherKit.Forecast<MinuteWeather>? { let minuteWeather = await Task.detached(priority: .userInitiated) { let forecast = try? await self.service.weather(for: location, including: .minute) return forecast }.value return minuteWeather } }
Replies
1
Boosts
1
Views
1k
Activity
Jul ’22
Does anyone's WeatherKit work on a real device?
I'm working on an app with WeatherKit. The app works on the simulator, but it doesn't work on the real device. Calling "weatherService.weather(for: ..." never returns data or an error. do { let weather = try await weatherService.weather(for: myPlace) print(weather) // always on the simulator, never on the device     } catch { // never gets a call    print(error) } I'm using the latest beta on my device. Apple's TestFlight sample app doesn't work on the device, but it works fine on the simulator. Does anyone's WeatherKit work on a real device?
Replies
2
Boosts
0
Views
1.5k
Activity
Jul ’22
WeatherKit iOS SDK 401 network error
I'm following along to the WWDC WeatherKit session, and I keep getting this 401 network error that causes my app to crash on a fatal error. I have already created the proper Bundle App ID with WeatherKit enabled, and added the WeatherKit capability. Here is my code: private func getWeather() async -> Double {         let weatherService = WeatherService()         let syracuse = CLLocation(latitude: 33.6846, longitude: 117.8265)         let weather = try! await weatherService.weather(for: syracuse)         let temperature = weather.currentWeather.temperature         return temperature.converted(to: .celsius).value     } Full error message: 2022-06-07 17:35:43.051776-0700 WWDC2022[56529:1296409] WWDC2022/WeatherView.swift:30: Fatal error: 'try!' expression unexpectedly raised an error: WeatherDaemon.WDSHMACJWTAuthenticatorService.Errors.invalidJWTResponse(Optional(<NSHTTPURLResponse: 0x6000018402c0> { URL: https://weather-data.apple.com/v2/token } { Status Code: 401, Headers {     Connection =     (         close     );     "Content-Length" =     (         0     );     Date =     (         "Wed, 08 Jun 2022 00:35:43 GMT"     );     Server =     (         Apple     );     "Strict-Transport-Security" =     (         "max-age=31536000; includeSubdomains"     );     "X-Apple-Origin" =     (         "8961098f-b238-3714-ba44-5b569c861456"     );     "X-Cache" =     (         "TCP_MISS from a23-219-38-54.deploy.akamaitechnologies.com (AkamaiGHost/10.8.2-41841244) (-)"     );     "X-Content-Type-Options" =     (         nosniff     );     "X-Frame-Options" =     (         SAMEORIGIN     );     "X-REQUEST-ID" =     (         "5156c5c7-d23b-4a66-a161-c8a9fb849c85"     );     "X-XSS-Protection" =     (         "1; mode=block"     ); } }))
Replies
26
Boosts
10
Views
7.7k
Activity
Jul ’22