SPLocationManager
Objective-C
@interface SPLocationManager : NSObject
Swift
class SPLocationManager : NSObject
Provides APIs for requesting users current location. To use this class you need to have a Steerpath API access token and provide it to the app according to the instructions in SPAccountManager.h.
Set delegate to listen for location updates.
Switches between GPS and indoor positioning automatically if GPS is enabled. To disable GPS see ‘useGPS’ property.
Automatically downloads positioning data when relevant beacons are detected. Requires internet access to download positioning data. After data is downloaded, positioning can be used without a connection.
If you wish to use positioning without downloading it you can use a bundled .sff file. See SPOfflineManager class documentation for more information about how to use .sff files.
Example on the basic usage of this class can be found at https://bitbucket.org/nimbledevices/steerpath-ios-examples/src/b9a1b96a86412a8690ac5c2168209f095a9af18e/ObjCExamples/ObjCExamples/MapWithPositioningViewController.m
-
Delegate for location callbacks
Declaration
Objective-C
@property (weak) id<SPLocationManagerDelegate> _Nullable delegate;
Swift
weak var delegate: SPLocationManagerDelegate? { get set }
-
Use this property to enable/disable GPS for location calculations.
By default GPS is disabled.
Declaration
Objective-C
@property (nonatomic) BOOL useGPS;
Swift
var useGPS: Bool { get set }
-
This determines the minimum accuracy that GPS must have in order for automatic bluetooth to GPS switch to happen. The smaller the value, the less likely the GPS will be used.
You may want to configure this to a lower value if you notice that your app is switching to GPS too aggressively inside your buildings. It is recommended that you do not set this value to be lower than 5 (meters)
By default the threshold is 10 (meters).
Declaration
Objective-C
@property (nonatomic) NSUInteger gpsThreshold;
Swift
var gpsThreshold: UInt { get set }
-
The device’s accelerometer can be used to significantly improve the accuracy of pedestrian positioning. If it is known that the user is not a pedestrian, then the use of the accelerometer will decrease accuracy.
By default true
Declaration
Objective-C
@property (nonatomic) BOOL useAccelerometer;
Swift
var useAccelerometer: Bool { get set }
-
The device’s compass can improve the accuracy of pedestrian positioning when the compass is accurate.
By default true
Declaration
Objective-C
@property (nonatomic) BOOL useCompass;
Swift
var useCompass: Bool { get set }
-
The device’s sensors such as gyro can be used to significantly improve accuracy of positioning and compass heading. If compass is disabled, the absolute orientation will be learned as the user walks around.
By default false
Declaration
Objective-C
@property (nonatomic) BOOL useDeviceMotion;
Swift
var useDeviceMotion: Bool { get set }
-
If enabled, SPLocationManager will attempt to update user location even when application is in a background state.
To receive background updates, make sure you your app has ‘Background Modes’ capabilities with the ‘Uses Bluetooth LE accessories’ enabled.
Disclaimer:
At the moment the SDK supports background updates only via bluetooth. It’s possible that background GPS will be added in the future. It’s very likely that background updates will have a worse accuracy than when the app is being actively used. It’s possible that the device is in a bag or a pocket that will reduce signal strength etc.
By default false
Declaration
Objective-C
@property (nonatomic) BOOL useBackgroundUpdates;
Swift
var useBackgroundUpdates: Bool { get set }
-
This determines the time interval between background location updates.
To receive background updates, make sure you your app has ‘Background Modes’ capabilities with the ‘Uses Bluetooth LE accessories’ enabled.
Disclaimer:
At the moment the SDK supports background updates only via bluetooth. It’s possible that background GPS will be added in the future. It’s very likely that background updates will have a worse accuracy than when the app is being actively used. It’s possible that the device is in a bag or a pocket that will reduce signal strength etc.
Must be a minimum of 5 seconds
By default 60 seconds
Declaration
Objective-C
@property (nonatomic) NSTimeInterval backgroundUpdateInterval;
Swift
var backgroundUpdateInterval: TimeInterval { get set }
-
Recommended constructor for SPLocationManager objects. Automatically starts positioning.
Declaration
Objective-C
- (nonnull instancetype)initWithDelegate: (nonnull id<SPLocationManagerDelegate>)delegate;
Swift
init(delegate: SPLocationManagerDelegate)
Parameters
delegate
for location callbacks
Return Value
new instance of SPLocationManager
-
Starts positioning. By default SPLocationManager will automatically start positioning when it’s initialized. Use this if you want to explicitly start positioning after you’ve stopped it at some point.
Declaration
Objective-C
- (void)start;
Swift
func start()
-
Stops positioning. This is recommended for situations when you don’t need positioning and want to save battery life.
Declaration
Objective-C
- (void)stop;
Swift
func stop()
-
Deprecated
This method will be removed in a future release. Please use SPOfflineManager features instead.
Use local file from your device bundle as the default positioning data. File should be located in your applications main bundle.
Declaration
Objective-C
- (void)setDefaultNDD:(nonnull NSString *)filename building:(nonnull NSString *)buildingIdentifier;
Swift
func setDefaultNDD(_ filename: String, building buildingIdentifier: String)
Parameters
filename
name of the resource eg. “a125s57b6fcdab3bb871197ad16231f35de.ndd”
buildingIdentifier
unique identifier for building
-
Debug configuration. Recommended you don’t use this unless you know what you’re doing.
Declaration
Objective-C
- (void)updateConfig:(nonnull NSDictionary *)config;
Swift
func updateConfig(_ config: [AnyHashable : Any])
Parameters
config
new configuration
-
Advanced way of generating device mappings from a local file. Will generate new device mappings from device metadata.
Declaration
Objective-C
- (void)generateMappings:(nonnull NSString *)filePath;
Swift
func generateMappings(_ filePath: String)
Parameters
filePath
file containing mapping metadata
-
Advanced way of adding pre-generated mappings from a local file.
Declaration
Objective-C
- (void)addMappings:(nonnull NSString *)filePath;
Swift
func addMappings(_ filePath: String)
Parameters
filePath
file containing pre-generated mapping information
-
Frequency for nearby beacon detection. Does not affect positioning. Most of the time this value should be left alone.
By default 20 seconds
Declaration
Objective-C
- (void)setDetectionInterval:(NSTimeInterval)seconds;
Swift
func setDetectionInterval(_ seconds: TimeInterval)
-
This method forces the location manager to always return a specific location when the following delegate method is being called: ‘-(void)spLocationManager:(SPLocationManager*)manager didUpdateLocation:(SPLocation*)location;’
Useful when developing an app without access to the actual area where indoor positioning is set up.
When you set a debug location, all ‘didUpdateLocation’ callbacks will return that location until you set another location or set the debug location to nil/null.
Declaration
Objective-C
- (void)setDebugLocation:(nullable SPLocation *)location;
Swift
func setDebugLocation(_ location: SPLocation?)
Parameters
location
debug location for testing and developing.
-
Debug grid. Can only be used in debug builds (does nothing).
Declaration
Objective-C
- (nonnull const uint16_t *)debugGrid:(NSUInteger)time width:(nonnull uint16_t *)width height:(nonnull uint16_t *)height lat:(nonnull double *)lat lon:(nonnull double *)lon;
Swift
func debugGrid(_ time: UInt, width: UnsafeMutablePointer<UInt16>, height: UnsafeMutablePointer<UInt16>, lat: UnsafeMutablePointer<Double>, lon: UnsafeMutablePointer<Double>) -> UnsafePointer<UInt16>
Parameters
time
t
width
w
height
h
lat
l
lon
l
Return Value
info