Map URL in app goes to Safari, not native map app - iphone

I am trying to use a URL to launch the native maps application. My build is for 3.1.3 and later. When I run the following code, safari launches with the URL instead of google maps:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://maps.google.com/maps"]];
Any suggestions?
Thanks!

It sounds to me like you are running on the simulator not hardware. This behavior occurs when the map app is not installed or if you are on the simulator.
If you are running on hardware - have you tried that same style with a specific query or location or with http://maps.google.com as the documentation you pointed to mentions that The path cannot be /maps/*. - I'm not sure if that means explicitly *. or if they mean a wildcard. I'm not really clear why you'd want to launch the map app without a specific query.

Your string needs to be #"maps://maps.google.com/...". That "maps" at the front of it is what triggers it to load the Maps.app application.

Related

how to change default browser on iphone?

I am new to iOS and I want to know that, How to change the default browser as Google chrome on iPhone Simulator?
Thank you in advance.
As xlc has mentioned the Simulator doesn't allow you to install third party applications. It's designed to let you test your code and how it interacts with iOS.
You cannot change default iOS default browser unless and until your device is jailbroken.
but you can open links in google chrome from your app using :
[[UIApplication sharedApplication] canOpenURL:
[NSURL URLWithString:#"googlechrome://http://www.nameofwebsitehere.com"]];
Note : this will not work on simulator and you should add a check to see if Google chrome is installed on device.

How to launch Google Maps on iPhone via web link?

I am building a site that will have address links as well as image of a map - both of which have a link to Google Maps.
The problem is that when I click on these links using my iPhone - or any address link that shows up in an email, the result is that either the native Apple Maps app opens or the Google Maps in the browser. I want for the native Google Maps app to open every time, and ideally for every user (whose iPhone I have no control of).
If I use the Chrome app for iPhone, then there's a little trick to do this:
http://www.redmondpie.com/how-to-set-google-maps-for-iphone-default-app-for-opening-map-links/
But the reality is that the trick above will not open the Google Maps app. It will open the web version of Google Maps inside the Chrome app. Then an icon shows up at the bottom asking if you want to open the native app instead. This is better than nothing, but far from ideal. I appreciate any help. Thank you. BTW, I'd like to do this without jailbreaking the iPhone - I'm looking for a solution that will work with other people's iPhones.
You can use apple's interface which is a bit more intelligent when using different browsers and devices:
http://maps.apple.com/?q=51.507269,-0.127695
Clicking the above url on the following devices:
iPhone|iPad:
Opens Apple maps app
Android:
Gives you a choice to open in either Google Maps App or Google maps website
Windows Phone:
Opens Google maps mobile website
Windows 8 Desktop:
Opens Google maps website
Apple OS Desktop:
Opens the new maps app (Mavericks)!!
For more info see:
Apple URL Scheme Reference
To open Google native app you need to write:
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"comgooglemaps://"]];
Example :
comgooglemaps://?q=Pizza&center=37.759748,-122.427135
I just tested this and it worked in pulling up Google Maps instead of the default Apple Maps application.
Testing Maps
However, after deleting the Google Maps app for iOS, the link fails to open anything because that schema is no longer available and doesn't fallback to a generic maps link... almost seems like you would need to provide two links for Google Maps for iPhone and another generic Apple Map link...
Take a look at this.
It works on every device (for ios / android, it will launch google maps app else browser).
For other devices, it will launch browser.
Simple use case would be:
Construct universal map URI (with encoded params)
Use this URL like -
window.open(mapUrl, '_system');
More info for window.open here
My use case required to open existing in app map navigation into some another dedicated maps app (preferably google maps app) for ios and android devices.
I use ionic v1 + cordova for building native apps. Not sure if this is perfect for your use case but hope this helps.

How to know google maps is installed in iPhone

I am developing an application in which i need to know which are already installed in iPhone device such as google maps. I need to check it. cause I know some country can't support google maps. In this case, what can I do that?
Normally you can't unless you find an API. And even if you find it, there are chances you get rejected from the AppStore.
However, you can try with the URL schemes. For Google Maps, it will invoke the application of it finds an URL starting with http://maps.google.com/.
So, add this function to your code :
- (BOOL)isGoogleMapsInstalled {
return [[UIApplication sharedApplication]
canOpenURL:[NSURL URLWithString:#"http://maps.google.com/maps?q=Paris"]];
}
It's not very "clean" but should works.

Launching web app from native app

Does anyone know how to launch a web app from a native app?
I assume that this is hard to achive, but the next best thing would be to launch safari with a specific URL, without the URL-bar. And I don't want it to be done within the app, I would prefer if the native app could go into a suspended state.
It's not hard to achieve, it's easy with UIWebView http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.makebetterthings.com/blogs/"]];
and enable multitasking in your app so when the safari opens your app will go in suspended mode.
Update -
Read my these blog entries -
http://www.makebetterthings.com/blogs/iphone/open-phone-sms-email-map-and-browser-apps-in-iphone-sdk/
http://www.makebetterthings.com/blogs/iphone/launching-your-own-application-via-a-custom-url-scheme/
unfortunately you can not open all the apps! but you can add custom URL scheme in your own app to open them

Open Photos app programmatically

Is it possible to launch the "Photos" application from an iPhone app? Similar to launching mail?
[[UIApplication sharedApplication] openURL:url];
The Photos app doesn't appear to register any URL schemes that other apps can use. There's a pretty well-established pattern in other system apps (e.g. Safari) of “saving an image” resulting in that image being placed in the user's camera roll; I'd recommend just sticking with that expected behavior, and perhaps using an alert to direct the user to look there for your app's exported image.
This article looks like it might be useful?
Getting images from the iPhone