WeatherContext
Objective-C
@interface WeatherContext : NSObject
Swift
class WeatherContext : NSObject
This class handles the weather information.
-
Returns the singleton SDK instance.
Declaration
Objective-C
+ (nonnull instancetype)shared;
Swift
class func shared() -> Self
-
Async gets current weather for a list of coordinates.
Declaration
Objective-C
- (SDKErrorCode) requestCurrentForecast:(nonnull NSArray<CoordinatesObject *> *)coordinates completionHandler: (nonnull void (^)(SDKErrorCode, NSArray<WeatherContextForecast *> *_Nonnull)) handler;
Swift
func requestCurrentForecast(_ coordinates: [CoordinatesObject], completionHandler handler: @escaping (SDKErrorCode, [WeatherContextForecast]) -> Void) -> SDKErrorCode
Parameters
coordinates
The coordinates list for which the weather is requested.
completionHandler
The completion handler with the operation code and the array with weather conditions for every requested coordinates.
Return Value
Error code if the operation couldn’t start. If operation successfully started the completion notifications will come with the result.
-
Async gets daily forecast weather for a list of coordinates.
Declaration
Objective-C
- (SDKErrorCode) requestDailyForecast:(nonnull NSArray<CoordinatesObject *> *)coordinates days:(NSInteger)days completionHandler: (nonnull void (^)( SDKErrorCode, NSArray<NSArray<WeatherContextForecast *> *> *_Nonnull))handler;
Swift
func requestDailyForecast(_ coordinates: [CoordinatesObject], days: Int, completionHandler handler: @escaping (SDKErrorCode, [[WeatherContextForecast]]) -> Void) -> SDKErrorCode
Parameters
coordinates
The coordinates list for which the weather is requested.
days
The number of days for which the forecast is requested ( value should be <= 10 ).
completionHandler
The completion handler with the operation code and the array with weather conditions for every requested coordinates.
Return Value
Error code if the operation couldn’t start. If operation successfully started the completion notifications will come with the result.
-
Async gets hourly forecast weather for a list of coordinates.
Declaration
Objective-C
- (SDKErrorCode) requestHourlyForecast:(nonnull NSArray<CoordinatesObject *> *)coordinates hours:(NSInteger)hours completionHandler: (nonnull void (^)( SDKErrorCode, NSArray<NSArray<WeatherContextForecast *> *> *_Nonnull))handler;
Swift
func requestHourlyForecast(_ coordinates: [CoordinatesObject], hours: Int, completionHandler handler: @escaping (SDKErrorCode, [[WeatherContextForecast]]) -> Void) -> SDKErrorCode
Parameters
coordinates
The coordinates list for which the weather is requested.
hours
The number of hours for which the forecast is requested ( value should be <= 240 )
completionHandler
The completion handler with the operation code and the array with weather conditions for every requested coordinates.
Return Value
Error code if the operation couldn’t start. If operation successfully started the completion notifications will come with the result.
-
Async gets forecast weather for a list of coordinates and timestamps.
Declaration
Objective-C
- (SDKErrorCode) requestForecast:(nonnull NSArray<TimeDistanceCoordinatesObject *> *) timeDistanceCoordinates completionHandler: (nonnull void (^)( SDKErrorCode, NSArray<NSArray<WeatherContextForecast *> *> *_Nonnull))handler;
Swift
func requestForecast(_ timeDistanceCoordinates: [TimeDistanceCoordinatesObject], completionHandler handler: @escaping (SDKErrorCode, [[WeatherContextForecast]]) -> Void) -> SDKErrorCode
Parameters
timeDistanceCoordinates
The time distance coordinates list for which the forecast weather is requested. The timestamp should be relative to current time.
completionHandler
The completion handler with the operation code and the array with weather conditions for every requested coordinates.
Return Value
Error code if the operation couldn’t start. If operation successfully started the completion notifications will come with the result.
-
Cancel async operations.
Declaration
Objective-C
- (void)cancelRequests;
Swift
func cancelRequests()
-
Get max coordinates per request limit.
Declaration
Objective-C
- (int)getMaxCoordinatesPerRequest;
Swift
func getMaxCoordinatesPerRequest() -> Int32
-
Get max day for daily forecast limit.
Declaration
Objective-C
- (int)getMaxDayForDailyForecast;
Swift
func getMaxDayForDailyForecast() -> Int32
-
Get max hours for hourly forecast limit.
Declaration
Objective-C
- (int)getMaxHoursForHourlyForecast;
Swift
func getMaxHoursForHourlyForecast() -> Int32
-
Get data transfer statistics for weather service.
Declaration
Objective-C
- (nonnull TransferStatisticsContext *)getTransferStatistics;
Swift
func getTransferStatistics() -> TransferStatisticsContext