我希望打开谷歌地图方向应用程序,如果它在那里我想在Safari浏览器中打开它。但我发现意外的行为是..而不是打开谷歌地图,它打开我的设备中安装的我的其他应用程序。
我用的代码。
if ([[UIApplication sharedApplication] canOpenURL:
[NSURL URLWithString:@"comgooglemaps://"]]) {
NSString *urlSring = [NSString stringWithFormat:@"comgooglemaps://?saddr=%f,%f&daddr=%f,%f",[IDUserDetails getUserCurrentLocation].latitude,[IDUserDetails getUserCurrentLocation].longitude,
deedModelShared.deedModel.deedCoordinate.latitude, deedModelShared.deedModel.deedCoordinate.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlSring] options:@{} completionHandler:^(BOOL success) {
}];
} else {
NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f",
[IDUserDetails getUserCurrentLocation].latitude,[IDUserDetails getUserCurrentLocation].longitude,
deedModelShared.deedModel.deedCoordinate.latitude, deedModelShared.deedModel.deedCoordinate.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url] options:@{} completionHandler:^(BOOL success) {
}];
}
url scheme
<key>LSApplicationQueriesSchemes</key>
<array>
<string>comgooglemaps</string>
</array>