0

I need to open native iOS maps app from my app using below code:

 NSString *urladdress = [NSString stringWithFormat:@"http://maps.apple.com/?q=%@",@"Texas,US"];
    NSURL *url = [NSURL URLWithString:urladdress];
    [[UIApplication sharedApplication] openURL:url];

And I have also configured .plist as shown in below image

enter image description here

When I run my code I found following error in my console as shown in below image

enter image description here

I have searched a lot of similar links in stack overflow like

iOS 9 safari iframe src with custom url scheme not working

iOS 9 custom URL scheme not working

Google Maps URL scheme not working on iOS 9

but I am not able to solve my issue.

I would like to request you all to solve my query or show me the right path whether I am going on wrong direction. IF any example in stack or in somewhere else which I have missed to refer please let me know.

Community
  • 1
  • 1
Jekil Patel
  • 403
  • 4
  • 18
  • AFAIK `LSApplicationQueriesScheme` is not required for native maps app. Probably there is an error in the formed URL. You could try examples from the [documentation](https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html) to see if really apps app is not invoked. eg: http://maps.apple.com/?address=1,Infinite+Loop,Cupertino,California – Vin Mar 15 '16 at 05:04
  • Vin, Thanks for your quick reply – Jekil Patel Mar 15 '16 at 05:08
  • FYI - `LSApplicationQueriesScheme` is only needed to call `canOpenURL:`, not `openURL:`. – rmaddy Mar 15 '16 at 05:10
  • Vin, Thanks for your quick reply. Could you post your comment through answer so i can upvote? – Jekil Patel Mar 15 '16 at 05:54
  • rmaddy, Thanks for your reply and kind suggestion. – Jekil Patel Mar 15 '16 at 05:54
  • @JekilPatel did you get it solved using http://maps.apple.com/?address=1,Infinite+Loop,Cupertino,California ? – Vin Mar 15 '16 at 06:13
  • @Vin Yes I got the solution from your comment, thanks. Please post your answer so i can upvote it. – Jekil Patel Mar 15 '16 at 07:05

1 Answers1

1

As mentioned by rmaddy

LSApplicationQueriesScheme is only needed to call canOpenURL:, not openURL:

Even if you were using canOpenURL:, it would not be required to add LSApplicationQueriesScheme in the Info.plist for invoking the native maps app.

There seems to be a problem with the parameteres of the URL that you are forming to invoke Maps app. Try using one of the URLs mentioned in the documentation.

For example, you could use this.

Vin
  • 10,517
  • 10
  • 58
  • 71