我正在尝试将最受欢迎的导航应用程序集成到我的应用程序中,除了Sygic之外,我选择的所有应用程序都工作。
关注this guide,我写了代码:
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
则不会(应该)。
我使用“Sygic Brasil”和“Sygic(所有地区)”进行了测试,版本13,但都没有打开。 我也尝试过百分比转义URL字符串,但这也不起作用。
答案 0 :(得分:6)
您尝试使用代码,
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");
}