我正在尝试将最流行的导航应用程序集成到我的应用程序中,除了Sygic之外,我选择的所有这些应用程序都可以工作。
按照本指南,我编写了代码:
NSString *URL = [NSString stringWithFormat:@"com.sygic.aura://coordinate|%f|%f|drive",
self.coordinate.longitude,
self.coordinate.latitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:URL]];
但是当代码运行时,Sygic 不会打开,也不会发生任何事情。
检查[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"com.sygic.aura://"]]
会在安装应用时返回YES
,在未安装应用时返回NO
(应该如此)。
Brasil"和"Sygic(所有区域)"版本13进行了测试,但两者都无法打开。我还尝试对 URL 字符串进行百分比转义,但这也没有用。
你尝试下面的代码,
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");
}