IS2Location Class Reference

Inherits from NSObject
Declared in IS2Location.h

Overview

IS2Location allows for querying data about the user’s current location, and also to be notified when the user changes location if so required.

Setup

+ registerForLocationNotificationsWithIdentifier:andCallback:

Sets a block to be called whenever location data changes. The identifier must be unique string; it is recommended to use reverse DNS notation, such as “com.foo.bar”.

+ (void)registerForLocationNotificationsWithIdentifier:(NSString *)identifier andCallback:(void ( ^ ) ( void ))callbackBlock

Parameters

identifier

The identifier associated with your callback

callbackBlock

The block to call once data changes

Declared In

IS2Location.h

+ unregisterForNotificationsWithIdentifier:

The inverse of registering for notifications. This must be called when your code is unloaded, else your device may play Disney’s Let It Go at the worst possible moments.

+ (void)unregisterForNotificationsWithIdentifier:(NSString *)identifier

Parameters

identifier

The identifier associated with your callback

Declared In

IS2Location.h

Requesting data

+ requestUpdateToLocationData

Requests an immediate update to location data. Please note that this will not notify your callback for location changes if Location Services is disabled.

+ (void)requestUpdateToLocationData

Declared In

IS2Location.h

+ setLocationUpdateDistanceInterval:forRequester:

Sets the distance interval the user must travel before a location data update is performed. By default, this is set to “manual updating”, whereupon location data is only updated after calling requestUpdateToLocationData.

If another client of the InfoStats2 API has requested a more fine-grained distance interval, that more fine-grained interval will be used instead.

+ (void)setLocationUpdateDistanceInterval:(int)interval forRequester:(NSString *)requester

Parameters

interval

The interval to be requested for location data updates.

Available values:
1 - Update every 10 meters moved (walking or cycling)
2 - Update every 100 meters (driving or other such transport)
3 - Update every 500 meters
4 - Update every 1 kilometer (best for weather data)

requester

A unique identifier used to identify your code as requesting a particular interval. It is recommended to use reverse DNS notation, such as “com.foo.bar”.

Declared In

IS2Location.h

+ removeRequesterForLocationDistanceInterval:

Removes your code as requesting a particular update interval, as detailed in setLocationUpdateDistanceInterval:forRequester:. This must be called once your code is unloaded, else location data will continue to be updated, thus draining battery.

+ (void)removeRequesterForLocationDistanceInterval:(NSString *)requester

Parameters

requester

A unique identifier used to identify your code as requesting a particular interval. It is recommended to use reverse DNS notation, such as “com.foo.bar”.

Declared In

IS2Location.h

+ setLocationUpdateAccuracy:forRequester:

Sets the accuracy of the resulting location data. Please be aware though that the higher the accuracy, the faster the battery will drain. By default, this will be set to an accuracy of within 100 meters of the user.

If another client of the InfoStats2 API has requested a greater accuracy, that accuracy will be used instead.

+ (void)setLocationUpdateAccuracy:(int)accuracy forRequester:(NSString *)requester

Parameters

accuracy

The accuracy to be requested for location data updates.

Available values:
1 - Satellite navigation quality (GPS and additional sensors)
2 - Satellite navigation quality (GPS only)
3 - Within 10 meters of the user
4 - Within 100 meters
5 - Within 1 kilometer
6 - Within 3 kilometers

requester

A unique identifier used to identify your code as requesting a particular acuracy. It is recommended to use reverse DNS notation, such as “com.foo.bar”.

Declared In

IS2Location.h

+ removeRequesterForLocationAccuracy:

Removes your code as requesting a particular acuracy, as detailed in setLocationUpdateAccuracy:forRequester:. This must be called once your code is unloaded, else location data will continue to update at the accuracy requested; if greater in accuracy than to within 100 meters, this will result in increased battery drainage.

+ (void)removeRequesterForLocationAccuracy:(NSString *)requester

Parameters

requester

A unique identifier used to identify your code as requesting a particular interval. It is recommended to use reverse DNS notation, such as “com.foo.bar”.

Declared In

IS2Location.h

+ isLocationServicesEnabled

Checks if the user has enabled Location Services in Settings.

+ (BOOL)isLocationServicesEnabled

Declared In

IS2Location.h

Data retrieval

+ currentLatitude

The latitude of the user’s current location

+ (double)currentLatitude

Declared In

IS2Location.h

+ currentLongitude

The longitude of the user’s current location

+ (double)currentLongitude

Declared In

IS2Location.h

+ cityForCurrentLocation

The city the user’s current location is within.

+ (NSString *)cityForCurrentLocation

Declared In

IS2Location.h

+ neighbourhoodForCurrentLocation

The neighbourhood the user’s current location is within. This may return null; at the time of writing, it is unsure whether this only works in the United States.

+ (NSString *)neighbourhoodForCurrentLocation

Declared In

IS2Location.h

+ stateForCurrentLocation

The state the user’s current location is within. Note: not to be confused with county.

+ (NSString *)stateForCurrentLocation

Declared In

IS2Location.h

+ countyForCurrentLocation

The county the user’s current location is within.

+ (NSString *)countyForCurrentLocation

Declared In

IS2Location.h

+ countryForCurrentLocation

The country the user’s current location is within.

+ (NSString *)countryForCurrentLocation

Declared In

IS2Location.h

+ ISOCountryCodeForCurrentLocation

The ISO Country Code for the country the user’s current location is within.

+ (NSString *)ISOCountryCodeForCurrentLocation

Declared In

IS2Location.h

+ postCodeForCurrentLocation

The post code for where the user’s current location is located. When requesting a location update interval of 1 kilometer, this will not be accurate.

+ (NSString *)postCodeForCurrentLocation

Declared In

IS2Location.h

+ streetForCurrentLocation

The street name for where the user’s current location is located. When requesting a location update interval of 1 kilometer, this will not be accurate.

+ (NSString *)streetForCurrentLocation

Declared In

IS2Location.h

+ houseNumberForCurrentLocation

The house number for where the user’s current location is located. When requesting a location update interval of 1 kilometer, this will not be accurate.

+ (NSString *)houseNumberForCurrentLocation

Declared In

IS2Location.h