Meet WeatherKit

RSS for tag

Discuss the WWDC22 Session Meet WeatherKit

Posts under wwdc2022-10003 tag

16 Posts
Sort by:
Post not yet marked as solved
0 Replies
45 Views
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?
Posted
by Jklr.
Last updated
.
Post not yet marked as solved
1 Replies
259 Views
In the Meet WeatherKit video it is stated that "You can access historical data by specifying a start and end date to the hourly and daily requests.", but I'm not seeing a way to do that in the Swift API (I see it is there in the REST API). Am I missing something or is that just not implemented yet?
Posted
by karlh.
Last updated
.
Post not yet marked as solved
0 Replies
93 Views
Hi, I try to fetch weather information for multiple dates through a single query but I only get information for the first day. let today = Date() let tomorrow = Calendar.current.date(byAdding: DateComponents(day: 1), to: today)! let forecast = try? await WeatherService.shared.weather(for: location, including: .daily(startDate: today, endDate: tomorrow)) Can we get weather information for a range of day?
Posted Last updated
.
Post not yet marked as solved
2 Replies
103 Views
Hi, i've been playing with WeatherKit for the first 3 betas but each time I try to get the UV Index of a forecast I've got 0 as value. For example the hourly forecast of San Francisco at the time of writing is the following : Optional(WeatherKit.HourWeather(date: 2022-07-06 14:00:00 +0000, cloudCover: 0.98, condition: Drizzle, symbolName: "cloud.moon.rain", dewPoint: 21.87 °C, humidity: 0.95, isDaylight: false, precipitation: rain, precipitationChance: 0.44, precipitationAmount: 0.44 mm, snowfallAmount: 0.0 mm, pressure: 1000.93 mbar, pressureTrend: Steady, temperature: 22.67 °C, apparentTemperature: 24.89 °C, uvIndex: WeatherKit.UVIndex(value: 0, category: Low), visibility: 8977.97 m, wind: WeatherKit.Wind(compassDirection: South Southeast, direction: 151.0 °, speed: 32.34 km/h, gust: Optional(48.66 km/h)))) While the UV Index at the time from The Weather Network is supposed to be 4. I've got this issue since beta 1 and it's happening on every location I try. Is this happening as well to other people ? Is there anything on my side in term of configuration that I should do ?
Posted Last updated
.
Post marked as solved
25 Replies
2k Views
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"     ); } }))
Posted
by Jevon_Mao.
Last updated
.
Post not yet marked as solved
1 Replies
65 Views
The way I want to insert weather data is on a page that doesn't have a lot of space so I just wanted to put a text line that said " Weather: Clear with a High of 77 °F" or whatever the actual daily forecast is. Would that meet the attribution requirements? Additionally, with the link to other data sources does that have to be on the same page as the weather display or can I have it on my Help screen?
Posted
by Besqware.
Last updated
.
Post marked as solved
1 Replies
157 Views
According to the WeatherKit Documentation It says To provide weather information to a web app or other platform, like Android, use the WeatherKit REST API. For native iOS, macOS, tvOS, and watchOS apps, use WeatherKit. is it possible to use The WeatherKit REST API on a iOS native app below iOS 16? I don’t see us being able to drop iOS 15 support for at least a year or so.
Posted Last updated
.
Post not yet marked as solved
1 Replies
99 Views
Hi all, WeatherKit is working fine within my contentView. I am trying to use the WeatherKit within SiriKit Intent Definition files. I am trying to call let weather = try! await weatherService.weather(for: location) How can I handle my SiriKit intent with the async/await function? Latitude and longitude (location) will be provided as input values from Shortcuts App. Thanks
Posted Last updated
.
Post not yet marked as solved
1 Replies
124 Views
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
Posted Last updated
.
Post not yet marked as solved
2 Replies
321 Views
I have upgraded from macOS 12.5.4 to macOS 13 Beta 1. Haven't done anything odd. I am attempting to use WeatherKit but I am getting a lot of (odd) errors: The sample can't access the ~/Library/Weather/ folder despite it being set to read for users, others and group. (I've since switched to read and write for all, but no dice). Lots of other odd errors. 2022-06-11 22:52:26.720487+0100 PlayWithWeatherKit[16282:277975] [WeatherService] Couldn't get access to the /Library/Weather directory for the geocode Store. error=Error Domain=NSCocoaErrorDomain Code=257 "The file “Weather” couldn’t be opened because you don’t have permission to view it." UserInfo={NSUserStringVariant=(     Folder ), NSURL=file:///Users/tarasis/Library/Weather, NSFilePath=/Users/tarasis/Library/Weather, NSUnderlyingError=0x6000013d4b70 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} PlayWithWeatherKit[16282:277975] [] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception. PlayWithWeatherKit[16282:277975] [] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception. PlayWithWeatherKit[16282:277975] [WeatherDataService] Failed to create the weather data store, error=cantOpen(message: "authorization denied", location: TeaDB.Database.Location.path("/Users/tarasis/Library/Weather/weather-data.db")) PlayWithWeatherKit[16282:277991] [Metadata] unable to get a dev_t for store 1795162192. PlayWithWeatherKit[16282:277991] [] nehelper sent invalid response: <dictionary: 0x1ffa87480> { count = 1, transaction: 0, voucher = 0x0, contents = "XPCErrorDescription" => <string: 0x1ffa87618> { length = 18, contents = "Connection invalid" } } PlayWithWeatherKit[16282:277991] [] nw_parameters_set_source_application_by_bundle_id_internal Failed to convert from bundle ID (net.tarasis.test.wwdc.Playground) to UUID. This could lead to wrong data usage accounting. PlayWithWeatherKit[16282:277991] [connection] nw_endpoint_flow_validate_delegation [C1 weather-data.apple.com:443 in_progress parent-flow (satisfied (Path is satisfied), interface: en0, ipv4, ipv6, dns)] Network Delegation Failure: Invalid Bundle ID "net.tarasis.test.wwdc.Playground" [M] PlayWithWeatherKit[16282:277991] [] nw_resolver_can_use_dns_xpc_block_invoke Sandbox does not allow access to com.apple.dnssd.service PlayWithWeatherKit[16282:277991] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:14 Err:-1 Errno:1 Operation not permitted PlayWithWeatherKit[16282:277991] [connection] nw_resolver_create_dns_service_locked [C1.1] DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563) PlayWithWeatherKit[16282:277991] Connection 1: received failure notification PlayWithWeatherKit[16282:277991] Connection 1: failed to connect 10:-72000, reason -1 PlayWithWeatherKit[16282:277991] Connection 1: encountered error(10:-72000) PlayWithWeatherKit[16282:277975] Task <0D654665-D88F-4C81-ABDA-FBFAAC0B01E5>.<1> HTTP load failed, 0/0 bytes (error code: -1003 [10:-72000]) PlayWithWeatherKit[16282:277975] Task <0D654665-D88F-4C81-ABDA-FBFAAC0B01E5>.<1> finished with error [-1003] Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=-72000, NSUnderlyingError=0x6000013b0060 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0, ipv4, ipv6, dns, _kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <0D654665-D88F-4C81-ABDA-FBFAAC0B01E5>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(     "LocalDataTask <0D654665-D88F-4C81-ABDA-FBFAAC0B01E5>.<1>" ), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=https://weather-data.apple.com/v2/token, NSErrorFailingURLKey=https://weather-data.apple.com/v2/token, _kCFStreamErrorDomainKey=10} PlayWithWeatherKit[16282:277975] [WeatherService] Encountered an error when fetching weather data subset; location=<+37.32299800,-122.03218100> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2022/06/11, 22:52:26 British Summer Time,  error=Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=-72000, NSUnderlyingError=0x6000013b0060 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0, ipv4, ipv6, dns, _kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <0D654665-D88F-4C81-ABDA-FBFAAC0B01E5>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(     "LocalDataTask <0D654665-D88F-4C81-ABDA-FBFAAC0B01E5>.<1>" ), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=https://weather-data.apple.com/v2/token, NSErrorFailingURLKey=https://weather-data.apple.com/v2/token, _kCFStreamErrorDomainKey=10}
Posted
by tarasis.
Last updated
.
Post not yet marked as solved
13 Replies
1.4k Views
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
Posted
by rubynerd.
Last updated
.
Post not yet marked as solved
1 Replies
266 Views
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,
Posted
by cxcxcxcx.
Last updated
.
Post marked as solved
1 Replies
189 Views
Hello Everyone, In the example code, I'm trying to convert from Fahrenheit to Celsius, but I'm not succeeding. Output is always in Fahrenheit. My code is this:   func formattedTemperature(_ temp: Measurement<UnitTemperature>) -> String {         let tempC = temp.converted(to: .celsius)         return tempC.formatted(.measurement(width: .abbreviated, usage: .weather))     } In the simulator I also went into the settings and switched in General->Language/Region from F to C. But this also had not effect. Would anyone have an idea how to correct this? Thanks and best regards, Patrick
Posted
by PatDelft.
Last updated
.
Post not yet marked as solved
1 Replies
243 Views
Hi - I don't see anything in the documentation about which regions of the world the API will support e.g. US, Europe. I see there is an /api/v1/availability you can call but is there some rough guidelines around what areas are supported and which aren't. Thanks Mark.
Posted
by markdaws.
Last updated
.
Post not yet marked as solved
0 Replies
239 Views
To anyone it may help, I've put together an OpenAPI spec of the WeatherKit REST API, which you may find useful for client generation using one of the OpenAPI generators. https://github.com/vanshg/WeatherKit-OpenAPI
Posted
by vanshg.
Last updated
.