PDA

View Full Version : [iOS SDK] Background routing



lorenzosanti
10.12.2015, 11:16
I installed and tried the FrameworkiOSDemo app on my iPhone and tested the routing system.
If I try to lock the phone while the navigation is in progress, it stops util I unlock the phone (aka the app becomes active).

Is it possible to have the routing service active also when the app is running in background?

Adela_Silvia
10.12.2015, 14:02
You have in the demo project an example:
[SKPositionerService sharedInstance].worksInBackground = _configuration.allowBackgroundNavigation;
if (self.configuration.allowBackgroundNavigation) {
//notify the user that the navigaiton will continue while in background
UILocalNotification *backgroundLocalNotification = [[UILocalNotification alloc] init];

backgroundLocalNotification.alertBody = NSLocalizedString(kSKTBackgroundNavigationLocalNot ificationKey, nil);
backgroundLocalNotification.userInfo = @{ kBackgroundLocalNotificationKey : kBackgroundLocalNotificationKey };
[[UIApplication sharedApplication] scheduleLocalNotification:backgroundLocalNotificat ion];
}

And in the SDKTools documentation: http://developer.skobbler.com/getting-started/iosTools#sec08

lorenzosanti
11.12.2015, 15:40
Thank you Adela!

I'm going a little off topic now.. what if I would like to have the detailed route data (steps, turns, symbols etc.)?
I saw that it's possible to get these informations by sending a REST request to the web service, but I can't figure out how to get them using the SDK.

Adela_Silvia
14.12.2015, 16:06
Hi Lorenzo,

The SKRouteAdvice class stores information about a route advice: http://developer.skobbler.com/getting-started/ios#sec19


- (void)routingService:(SKRoutingService *)routingService didFinishRouteCalculationWithInfo:(SKRouteInformat ion*)routeInformation{
NSLog(@"Route is calculated.");
[routingService zoomToRouteWithInsets:UIEdgeInsetsZero duration:1]; // zoom to currrent route
NSArray *adviceList = [[SKRoutingService sharedInstance] routeAdviceListWithDistanceFormat:SKDistanceFormat Metric]; // array of SKRouteAdvice
}

lorenzosanti
14.12.2015, 16:16
Thank you again Adela! You've been super helpful, have a good one!