iphoneiosdictionaryapple-mapsmkmapitem

How to get back to my app after going to map app from my application in ios 6


I am using this code to display some location on map.

Class mapItemClass = [MKMapItem class];
if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)])
{
    // Create an MKMapItem to pass to the Maps app
    CLLocationCoordinate2D coordinate =
    CLLocationCoordinate2DMake(37.789658,-122.417479);
    MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate
                                                   addressDictionary:nil];
    MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
    [mapItem setName:@"My Place"];

    // Set the directions mode to "Walking"
    // Can use MKLaunchOptionsDirectionsModeDriving instead
    NSDictionary *launchOptions = @{MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving};
    // Get the "Current User Location" MKMapItem
    MKMapItem *currentLocationMapItem = [MKMapItem mapItemForCurrentLocation];
    // Pass the current location and destination map items to the Maps app
    // Set the direction mode in the launchOptions dictionary
    [MKMapItem openMapsWithItems:@[currentLocationMapItem, mapItem]
                   launchOptions:launchOptions];
}

This code is taking me to the apple map app which is present in my iphone, this is ok but it is not taking me back to my app. If any one know any solution to achieve this please suggest me. !!Thanks in advance.!!


Solution

  • Unfortunately what you want cannot be done.

    Once you send the user to another app, the only way for your app to become active again is for that app to specifically return the user to your app, or for the user to navigate back to your app.

    The maps application as of now will not return the user to your app. There is nothing you can do.