Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The main component responsible for navigation in Navmii SDK is NMNavigationSevice. You can access an instance of this class via NMSdknavigationService property:

Code Block
languagecpp
themeEclipse
NMNavigationService *navigationService = [NMSdk sharedInstance].navigationService;

Navmii SDK generates various navigation events. To be able to handle these events make one of your classes conform to NMNavigationServiceListener protocol and add an instance of this class to NMNavigationService listeners via addNavigationServiceListener: method:

Code Block
languagecpp
themeEclipse
[NMSdk sharedInstance.navigationService addNavigationServiceListener:yourListener];

You also can add multiple listeners to NMNavigationService instance.

These navigation events are:

  • change of GPS status
  • change of iOS location services authorization status
  • change of current position
  • update of navigation information (see Navigation Info section)
  • change of country of current location
  • update of guidance info (see Guidance (v2))
  • passing a waypoint
  • reaching the destination
  • demo route start
  • demo route stop

You can set up the location detection accuracy in meters via locationDetectionAccuracy property. To retrieve user defined CLAuthorizationStatus use locationServicesAuthorizationStatus readonly property. You The onLocationServicesAuthorizationChanged: method will be called when this status changes. You can allow or disallow location updates when your app is in background mode via allowsBackgroundLocationUpdates BOOL property. 

Code Block
languagecpp
themeEclipse
//sets location detection accuracy to 20 meters
[[NMSdk sharedInstance].navigationService setLocationDetectionAccuracy:20];
//allows user's location updates in the background mode
[[NMSdk sharedInstance].navigationService setAllowsBackgroundLocationUpdates:YES];


Code Block
languagecpp
themeEclipse
//logs out location services authorization status on change
- (void)onLocationServicesAuthorizationStatusChanged:(CLAuthorizationStatus)status {
	NSLog(@"authorization status - %d", status);
}

When the authorization status is not determined you can prompt the user to allow/disallow location updates throughout requestAlwaysAuthorization and requestWhenInUseAuthorization methods:

Code Block
languagecpp
themeEclipse
[[NMSdk sharedInstance].navigationService.locationServicesAuthorizationStatus);
 There
 requestAlwaysAuthorization];
//or, alternatively
[[NMSdk sharedInstance].navigationService requestWhenInUseAuthorization];

There is also the gpsStatus property indicating if the SDK accepts GPS signal. GPS status is represented as NMGpsStatus enum

taking

of the following values:

  • NMGpsStatusOK
  • NMGpsStatusNoSignal
  • NMGpsStatusOff

The onGPSStatusChange: event in NMNavigationServiceListener protocol will bee triggered when the status changes:

Code Block
languagecpp
themeEclipse
//logs out a message if GPS signal is received by the SDK
if (- (void)onGpsStatusChange:(NMGpsStatus)status {
	NSLog(@"GPS status has changed to %d", (int)status);
}


The user's current position can be retrieved via NMNavigationService's currentPosition readonly property.

Code Block
languagecpp
themeEclipse
//logs out the user's current position
NMMapCoordinates *currentPosition = [NMSdk sharedInstance].navigationService.gpsStatus == NMGpsStatusOK) {
	currentPosition;
NSLog(@"GPS signal is received");
}You are at coordinates: %f lat. %f lon.", currentPosition.latitude, currentPosition.longitude);


Navmii SDK allows you to demonstrate the way the real-time traverse of the route will look like on the screen. When the route is calculated, use startDemoRoute and stopDemoRoute methods. Use isDemoRouteActive BOOL property to find out if the demo route is still in progress.


Code Block
languagecpp
themeEclipse
//starts demo route
[[NMSdk sharedInstance].navigationService startDemoRoute];
//stops demo route
[[NMSdk sharedInstance].navigationService stopDemoRoute];