The integration principle is the same accross all SDK services, so only the integration of the Location Service is detailed hereafter.
Please refer to the API Reference Guide for details about other services.
#import "NAOLocationHandle.h"
#import "NAOLocationHandleDelegate.h"
#import "NAOSyncDelegate.h"
#import "NAOSensorsDelegate.h"
#import "DBNAOERRORCODE.h"
#import "DBTNAOFIXSTATUS.h"
NAOSyncDelegate
, NAOLocationHandleDelegate
, NAOSensorsDelegate
protocols on any object of your choosing (e.g. a UIViewController
), You will then be able to receive the NAO engine callbacks.NAOLocationHandle
member (or property) as you will need this to interact with the Location service.@interface MyCustomViewController : UIViewController <NAOSyncDelegate, NAOLocationHandleDelegate, NAOSensorsDelegate> {
NAOLocationHandle * mLocationHandle;
}
@end
NAOLocationHandle
object, configure it with your API key and your delegates:mLocationHandle = [[NAOLocationHandle alloc] initWithKey:@"YOUR_API_KEY"
delegate:/* your (id<NAOLocationHandleDelegate>) */
sensorsDelegate:/* your (id<NAOSensorsDelegate>) */];
[mlocationHandle synchronizeData:/* your (id<NAOSyncDelegate>) */];
[mlocationHandle start];
The recommended call flow is to first call synchronizeData(), then the Services start() method. The NAO SDK will internally detect that a synchronization is ongoing, and update everything automatically. In the event that the synchronization would not go through, but a previous was already downloaded/embedded, the NAO SDK would still be able to run.
- (void)didSynchronizationSuccess {
// sync OK ! The new files will be taken into account automatically by the NAO SDK, no need to restart it.
}
- (void)didSynchronizationFailure:(DBNAOERRORCODE)errorCode msg:(NSString*) message {
// synchronization failed, check error code and message !
}
[mlocationHandle stop];
- (void) requiresWifiOn {
// warn the user (ie. with an UIAlertController)
}
- (void) requiresBLEOn {
// warn the user (ie. with an UIAlertController)
}
- (void) requiresLocationOn {
// warn the user (ie. with an UIAlertController)
}
- (void) requiresCompassCalibration {
// warn the user (ie. with an UIAlertController)
}
- (void) didLocationChange:(CLLocation *) location {
// a new location has been received !
// you can display the user location to your map here
}
The location given by the NAOLocationHandle is in a WGS84 format (like GPS) and it is encapsulated into a standard CLLocation object.
The following fields are used:
- (void) didLocationStatusChanged:(DBTNAOFIXSTATUS)status {
}
- (void) didFailWithErrorCode:(DBNAOERRORCODE)errCode andMessage:(NSString *)message {
NSLog(@"Location Error: %@", message);
}