Pregunta

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.!!

¿Fue útil?

Solución

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.

Otros consejos

Like Daniel said, there is nothing you can do if you choose to open Apple Maps.
However, if Google Maps App for iOS is an option,
Google Maps App can be opened with a callback URL specified.

Google Maps SDK
Check the section under Specify a callback URL

A banner will shows up on the top of Google Maps and once clicked on it will return the user back to your app (or whichever url you specified).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top