0

I'd like to support iOS5 in my app which I compile with the iOS 6.1 SDK.

One functionality is to take the User to the Maps App. Here is a link explaining how to do it with iOS SDK 5 for iOS 5 and also with iOS SDK 6 for iOS 6.

However, if I use iOS 6.1 SDK and use a iOS 5 device, the magic URL link takes me to the maps.google.com Website in Mobile Safari, not the native Maps App, as desired.

Can this be fixed?

EDIT

So far, I have this:

BOOL appleMapsSupported = FALSE;
NSString *reqSysVer = @"6.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
    appleMapsSupported = TRUE;
if (appleMapsSupported){
    NSLog(@"device version %@", [[UIDevice currentDevice] systemVersion]);
    MKPlacemark* placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate addressDictionary:@{(NSString*)kABPersonAddressStreetKey:@"Your Place"}];
    MKMapItem* mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
    [mapItem openInMapsWithLaunchOptions:@{MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeWalking}];
}else{
    NSString* url = [NSString stringWithFormat:@"http://maps.google.com/?t=m&q=Your+Place%%40%g,%g", coordinate.latitude, coordinate.longitude];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
Community
  • 1
  • 1
ilmiacs
  • 2,566
  • 15
  • 20

2 Answers2

2

Apple have updated their URL handling for maps, you need to point to maps.apple.com, which will appropriately re-direct to Google. See the documentation for more/how.

WDUK
  • 18,870
  • 3
  • 64
  • 72
  • Just replaced `maps.google.com` with `maps.apple.com` in my app and tested, but the same problem persists. – ilmiacs Feb 15 '13 at 17:47
  • This may be a bug then, the bottom of (http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/MapKit/MapKit.html#//apple_ref/doc/uid/TP40009497-CH3-SW1) states that for iOS 5, you need to use the URL scheme. This links to the same page I did. – WDUK Feb 15 '13 at 18:15
  • +1 You pointed me to the right direction. Reading the specs more thoroughly, the URL has to start with `http://maps.apple.com/?q`. (the `?q` being critical.) Now it works. :-) Thanks! – ilmiacs Feb 15 '13 at 18:20
0

The linked answer looks fine. All you need to do is to check which version of iOS the user is running on, via something like this, and execute the appropriate code for the iOS 6 case and the iOS less-than-6 case.

Community
  • 1
  • 1
bdesham
  • 15,430
  • 13
  • 79
  • 123