问题
I am new to iOS and I want to run navigation app from my own app. For now I just use this code:
- (void)navigationButtonTap:(id)sender
{
Class mapItemClass = [MKMapItem class];
if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)])
{
// Create an MKMapItem to pass to the Maps app
CLLocationCoordinate2D coordinate =
CLLocationCoordinate2DMake([actualPlace.latitude doubleValue], [actualPlace.longitude doubleValue]);
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate
addressDictionary:nil];
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
[mapItem setName:actualPlace.Name];
// Pass the map item to the Maps app
[mapItem openInMapsWithLaunchOptions:nil];
}
}
and it's working and I know how can I change it to run Apple maps with navigation started. It's okay but now I am thinking about some 3rd party options. How it's with other navigation apps like Google maps and others? Can iOS users set them as default and use them? How can I give user options to launch app which he wants?
I found code for implementing Google Maps option. But it's different code from Apple maps. Can I have same code for all navigation apps and then user decides which to run?
回答1:
You can launch 3rd party navigation apps and hand over an address or geo location only, when the other app conforms/implements an url schema. Some navigation apps actually do that.
来源:https://stackoverflow.com/questions/22767311/ios-run-3rd-party-navigation-app-from-code