我正在向我的应用程序添加一些位置。我有它默认在Apple地图中打开这些位置的位置。但我想把它放在哪里,如果用户下载了谷歌地图,他们可以选择在谷歌地图中打开它。那么如何在 Objective-c 中获取 Xcode 以查看用户的手机上是否有 Google 地图?我过去的做法似乎不再奏效了。
这是我一直在使用的
-(IBAction)parkerMap {
{
BOOL isAppInstalled=[[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"google.maps://"]];
if(isAppInstalled)
{
UIAlertController* maps = [UIAlertController alertControllerWithTitle:@"" message:@"Would you like to open in Apple or Google Maps?"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* appleAction = [UIAlertAction actionWithTitle:@"Apple" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://maps.apple.com/?address=68,D.L.WeatherlyLn.,38388"] options:@{} completionHandler:nil];
}];
UIAlertAction* googleAction = [UIAlertAction actionWithTitle:@"Google" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.google.com/maps/place/68+D.L.+Weatherly+Ln,+Wildersville,+TN+38388/ @35.7776813,-88.3943264,17z/data=!3m1!4b1!4m5!3m4!1s0x887c717763333487:0x8ac40c35453bbb84!8m2!3d35.777677!4d-88.3921377"] options:@{} completionHandler:nil];
}];
[maps addAction:appleAction];
[maps addAction:googleAction];
[self presentViewController:maps animated:YES completion:nil];
}
else
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://maps.apple.com/?address=68,D.L.WeatherlyLn.,38388"] options:@{} completionHandler:nil];
}
}
}