Meet WeatherKit in WWDC22
Meet WeatherKit in WWDC22
WWDC22: Meet WeatherKit 重點結錄
Meet WeatherKit in WWDC22
WWDC22: Meet WeatherKit 重點結錄
Meet WeatherKit - WWDC22 - Videos - Apple Developer
_WeatherKit offers valuable weather data for your apps and services to help people stay up to date on the latest…_developer.apple.com
提供的資料
- 現在天氣
- 天氣預報: 日/時/分 等級
- 風向/風力
- 日出/日落/月相
- 歷史天氣資料
- 有更多沒列出來的,都在文件上
收費標準 (Platform State of the Union)
- 500K calls/ month 以下是免費
- 有更高需求的話,也有其他附費方案 1M calls/ Month 定價 $49.99
500k 以下免費
需要有更高流量,也有各種 plan 可選
可以想見,接下來的 weather app ,會像雨後春筍一般冒出來
呼叫 WeatherKit 的方法短短幾行就能做到
Apple 也提供了 RESTful API 的方法呼叫 WeatherKit
/* Request a token */const tokenResponse = await fetch('<https://example.com/token>');const token = await tokenResponse.text();
/* Get my weather object */const url = "<https://weatherkit.apple.com/1/weather/en-US/41.029/-74.642?dataSets=weatherAlerts&country=US>"
const weatherResponse = await fetch(url, {headers: {"Authorization": token}});const weather = await weatherResponse.json();
/* Check for active weather alerts */const alerts = weather.weatherAlerts;const detailsUrl = weather.weatherAlerts.detailsUrl;
Apple WeatherKit document
https://developer.apple.com/documentation/weatherkit
By Marvin Lin on June 9, 2022.