1

I am trying to integrate the most popular navigation apps into my app, and all of those I chose work, except for Sygic.

Following this guide, I wrote the code:

NSString *URL = [NSString stringWithFormat:@"com.sygic.aura://coordinate|%f|%f|drive",
                                           self.coordinate.longitude,
                                           self.coordinate.latitude];
      
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:URL]];

But when the code is run, Sygic doesn't open, nothing happens.

Checking [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"com.sygic.aura://"]] returns YES when the app is installed and NO when it's not (as it should).

I tested using "Sygic Brasil" and "Sygic (All Regions)", version 13, but neither will open. I also tried percent-escaping the URL string, and that didn't work either.

Community
  • 1
  • 1
Guilherme
  • 7,839
  • 9
  • 56
  • 99

1 Answers1

6

you try following code,

NSString *URL = [NSString stringWithFormat:@"com.sygic.aura://coordinate|%f|%f|drive",
                                       self.coordinate.longitude,
                                       self.coordinate.latitude];

NSURL *newURL = [NSURL URLWithString:[URL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ];

if(newURL)
{
   [[UIApplication sharedApplication] openURL:newURL];
}
else
{
   NSLog(@"Something wrong with lat or long or both");
}
2intor
  • 1,044
  • 1
  • 8
  • 19
  • Add `http://` here also. Even I am able to open url in safari, but its unable to open page. For me your url is http://com.sygic.aura://coordinate%7C78.345000%7C17.989000%7Cdrive – Bhumeshwer katre Dec 26 '13 at 13:04
  • Actually, your first answer was right. I was using stringBy **Replacing** instead of **Adding**. Of course that wouldn't escape correctly. And the URL used has to be the one I used in first place (without `http://`). – Guilherme Dec 26 '13 at 13:14
  • please try simple http url like "http://www.google.com" if that does not work check this link http://stackoverflow.com/questions/8677087/uiapplication-sharedapplicationopenurl-can-not-launch-safari – 2intor Dec 26 '13 at 13:15