ios sdk maneuver instructionsForLanguage:language unitSystem array empty

46 Views Asked by At

I am working on developing the cordova HERE map plugin to get route calculation data in app. I am working on adding the functionality for ios. I want to get a maneuver instructions for the route, following is my code to get maneuver instructions for the calculated route.


NSString * language = [[NSLocale preferredLanguages] firstObject]; // getting lang code en

 NSArray* inst= [route instructionsForLanguage:language unitSystem:NMARouteInstructionsUnitSystemMetric];

But I don't know why it is returning empty array. Please help it anyone knows how to get maneuver instructions.

1

There are 1 best solutions below

3
On

That happening because NSLocale preferredLanguages can give you language code instead of language and country code, for example

[NSLocale preferredLanguages] // -> tr

According to HERE maps documentation function expect language code, like en-US

language should be a valid code according to the IETF BCP-47 standard (see http://tools.ietf.org/html/bcp47 ).

So to make it easier for you, to need to get language code instead.

NSLocale *locale = [NSLocale currentLocale];
NSString *language = [NSString stringWithFormat: "%@-%@", [locale languageCode], [locale countryCode]]; // -> tr-TR