1.0.0 • Published 2 months ago

@sprintwerk/capacitor-weatherkit v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@sprintwerk/capacitor-weatherkit

Capacitor plugin for iOS to get current weather and weather forecast via Apple WeatherKit

About this plugin

This Capacitor plugin provides native access to Apple WeatherKit, which has a generous free tire available. Make sure to follow these instructions to set up WeatherKit for your app.

Android Support

This plugin is iOS only as WeatherKit natively is only available on iOS devices. However Apple offers a WeatherKit REST API which can be used on other platforms like Android and web. We are currently developing a NodeJS package (@sprintwerk/node-weatherkit) that aims to provide easy access to the WeatherKit REST API while trying to maintain the same data schema as this Capacitor plugin returns. Check out this repo and make sure to set enableCapacitorPluginSchema to true in the client config.

Plugin author

This plugin is actively being developed and maintained by Sprintwerk. We are experts in all things Ionic and Capacitor and provide tailored solutions from consulting to full stack development. Have a project? Need some support? Just drop us a line.

Pull requests, featrue requests or any constructive feedback for this plugin are always appreciated!

Install

npm install @sprintwerk/capacitor-weatherkit
npx cap sync

API

getAvailability(...)

getAvailability(options: { latitude: number; longitude: number; }) => Promise<WeatherAvailability>

Get weather data availability for a location

ParamTypeDescription
options{ latitude: number; longitude: number; }Location coordinates

Returns: Promise<WeatherAvailability>


getCurrentWeather(...)

getCurrentWeather(options: { latitude: number; longitude: number; }) => Promise<WeatherData>

Get current weather conditions for a location

ParamTypeDescription
options{ latitude: number; longitude: number; }Location coordinates

Returns: Promise<WeatherData>


getDailyForecast(...)

getDailyForecast(options: { latitude: number; longitude: number; }) => Promise<{ forecast: DailyForecast[]; }>

Get daily forecast for a location

ParamTypeDescription
options{ latitude: number; longitude: number; }Location coordinates

Returns: Promise<{ forecast: DailyForecast[]; }>


Interfaces

WeatherAvailability

WeatherAvailability represents the availability of data at the requested location. Weather alerts, or minute forecast data may be temporarily unavailable from the data provider, or unsupported in some regions. Other data sets are expected to be supported for all geographic locations, for example, current weather, and therefore are not included in WeatherAvailability.

PropTypeDescription
minuteAvailabilityWeatherAvailabilityKindAvailability of minute-by-minute forecasts
alertAvailabilityWeatherAvailabilityKindAvailability of weather alerts

WeatherData

PropTypeDescription
apparentTemperaturenumberTemperature in Celsius
dewPointnumberTemperature in Celsius
humiditynumberRelative humidity (0-1)
temperaturenumberTemperature in Celsius
pressurenumberPressure in hectopascals (hPa)
pressureTrendPressureTrendInfo
windWind
cloudCovernumberCloud cover percentage (0-1)
cloudCoverByAltitudeCloudCoverByAltitudeCloud cover by altitude (iOS 18+ only)
conditionWeatherDescription
datestring
isDaylightboolean
uvIndexUVIndex
visibilitynumberVisibility in meters
metadataWeatherMetadata
symbolNamestring
precipitationIntensitynumberPrecipitation intensity in meters per second
attributionWeatherAttributionAttribution for the weather data

PressureTrendInfo

Pressure trend information

PropType
valuePressureTrend
descriptionstring
accessibilityDescriptionstring

Wind

Wind data with speed, direction, and gust information

PropTypeDescription
speednumberWind speed in meters per second (m/s)
compassDirectionWindCompassDirection
directionnumberWind direction in degrees (0-360)
gustnumber | nullWind gust in meters per second (m/s)

WindCompassDirection

Wind direction information

PropType
valueWindDirection
abbreviationstring
descriptionstring
accessibilityDescriptionstring

CloudCoverByAltitude

Cloud cover information by altitude

PropTypeDescription
lownumberLow altitude cloud cover (0-1)
mediumnumberMedium altitude cloud cover (0-1)
highnumberHigh altitude cloud cover (0-1)

WeatherDescription

Describes a value with human-readable descriptions

PropType
valuestring
descriptionstring
accessibilityDescriptionstring

UVIndex

UV index information

PropType
valuenumber
categoryUVIndexCategory

WeatherMetadata

Metadata about the weather data

PropType
datestring
expirationDatestring
locationCoordinates

Coordinates

Location coordinates

PropType
latitudenumber
longitudenumber

WeatherAttribution

Weather service attribution information

PropTypeDescription
serviceNamestringName of the weather data provider
legalPageUrlstringURL to the legal information page
squareMarkUrlstringURL to the square mark image
combinedMarkDarkUrlstringURL to the combined mark image for dark mode

DailyForecast

PropTypeDescription
datenumber
highTemperaturenumberTemperature in Celsius
lowTemperaturenumberTemperature in Celsius
precipationWeatherDescription
precipitationChancenumberPrecipitation chance (0-1)
precipitationAmountByTypePrecipitationAmountByType
moonMoonData
sunSunTimes
windWind
conditionWeatherDescription
uvIndexUVIndex
symbolNamestring
daytimeForecastDayPartForecastDaytime forecast (iOS 18+ only)
overnightForecastDayPartForecastOvernight forecast (iOS 18+ only)
restOfDayForecastDayPartForecastRest of day forecast (iOS 18+ only)
highTemperatureTimestringHigh temperature time
highWindSpeednumberWind speed in meters per second (m/s)
lowTemperatureTimestring
maximumHumiditynumberMaximum relative humidity (0-1)
maximumVisibilitynumberMaximum visibility in meters
minimumHumiditynumberMinimum relative humidity (0-1)
minimumVisibilitynumberMinimum visibility in meters
attributionWeatherAttributionAttribution for the weather data

PrecipitationAmountByType

Precipitation amounts by type

PropTypeDescription
rainnumberAmount in millimeters
snowSnowMeasurementSnow measurements in millimeters
sleetnumberAmount in millimeters
hailnumberAmount in millimeters
mixednumberAmount in millimeters
totalnumberTotal amount in millimeters

SnowMeasurement

Snow precipitation measurements

PropTypeDescription
amountnumberCurrent snow amount in millimeters
amountLiquidEquivalentnumberCurrent liquid water equivalent in millimeters
maximumnumberMaximum expected snow amount in millimeters
maximumLiquidEquivalentnumberMaximum expected liquid water equivalent in millimeters
minimumnumberMinimum expected snow amount in millimeters
minimumLiquidEquivalentnumberMinimum expected liquid water equivalent in millimeters

MoonData

Moon phase and timing information

PropType
moonRisestring | null
moonSetstring | null
phasestring

SunTimes

Astronomical data for sun positions

PropType
astronomicalDawnstring | null
astronomicalDuskstring | null
civilDawnstring | null
civilDuskstring | null
nauticalDawnstring | null
nauticalDuskstring | null
solarMidnightstring | null
solarNoonstring | null
sunrisestring | null
sunsetstring | null

DayPartForecast

PropTypeDescription
cloudCovernumberCloud cover percentage (0-1)
cloudCoverByAltitudeCloudCoverByAltitudeCloud cover by altitude (iOS 18+ only)
conditionWeatherDescriptionCondition
highTemperaturenumberTemperature in Celsius
lowTemperaturenumberTemperature in Celsius
highWindSpeednumberWind speed in meters per second (m/s)
maximumHumiditynumberMaximum relative humidity (0-1)
maximumVisibilitynumberMaximum visibility in meters
minimumHumiditynumberMinimum relative humidity (0-1)
minimumVisibilitynumberMinimum visibility in meters
precipitationChancenumberPrecipitation chance (0-1)
precipitationWeatherDescription
precipitationAmountByTypePrecipitationAmountByType
windWind

Enums

WeatherAvailabilityKind

MembersValue
Available'available'
TemporarilyUnavailable'temporarilyUnavailable'
Unknown'unknown'
Unsupported'unsupported'

PressureTrend

MembersValue
Falling"falling"
Rising"rising"
Steady"steady"

WindDirection

MembersValue
East"east"
EastNortheast"eastNortheast"
EastSoutheast"eastSoutheast"
North"north"
NorthNortheast"northNortheast"
NorthNorthwest"northNorthwest"
Northeast"northeast"
Northwest"northwest"
South"south"
SouthSoutheast"southSoutheast"
SouthSouthwest"southSouthwest"
Southeast"southeast"
Southwest"southwest"
West"west"
WestNorthwest"westNorthwest"
WestSouthwest"westSouthwest"

UVIndexCategory

MembersValue
Extreme"extreme"
VeryHigh"veryHigh"
High"high"
Moderate"moderate"
Low"low"
1.0.0

2 months ago

1.0.0-beta.1

2 months ago

1.0.0-beta.0

2 months ago