OpenWeatherProvider

@objcMembers
@objc(PESDKOpenWeatherProvider)
public class OpenWeatherProvider : NSObject, WeatherProvider, CLLocationManagerDelegate

A WeatherProvider for the https://openweathermap.org service.

Properties

  • The used API key. If nil or empty the sample API is used.

    Declaration

    Swift

    public let apiKey: String?
  • The minimum update interval to request new data from the service. It defaults to one hour.

    Declaration

    Swift

    public var updateInterval: TimeInterval

Initializers

  • Create a new OpenWeatherProvider.

    Declaration

    Swift

    public init(apiKey: String?, unit: TemperatureFormat)

    Parameters

    apiKey

    The used API key. If nil or empty the sample API is used.

    unit

    The temperature format that should be used for displaying temperature measurements to the user.

WeatherProvider

  • The temperature format that should be used for displaying temperature measurements to the user.

    Declaration

    Swift

    public var temperatureFormat: TemperatureFormat
  • The temperature measurement.

    Declaration

    Swift

    public var temperature: Temperature? { get }
  • Request to update the weather data.

    Declaration

    Swift

    public func updateData()

CoreLocation

  • When this closure is called, the SDK has determined that location access has not been granted to the host app yet. Within this closure you should then request appropriate permissions from the passed in CLLocationManager object. Location access is used to request weather data for the current location for weather stickers.

    Attention

    Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string as soon as location permissions requests appear somewhere in the binary. Since we do not want to force developers integrating the SDK into their app to include a purpose string even with weather stickers disabled, this closure was introduced, so that developers can decide for themselves if it is appropriate to request location access. Simply set this property like this: openWeatherProvider.locationAccessRequestClosure = { locationManager in locationManager.requestWhenInUseAuthorization() }

    Declaration

    Swift

    public var locationAccessRequestClosure: ((CLLocationManager) -> Void)? { get set }