I'm trying to open Google Maps app when I click on embed google maps sdk in Xcode. Please help me in order to find the solution?
Add one key in .plist file "LSApplicationQueriesSchemes" and mention one item "comgooglemaps" in that.
Then try this code.
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:#"comgooglemaps:"]]) {
NSURL *directionsURL = [NSURL URLWithString:#"comgooglemaps://"];
[[UIApplication sharedApplication] openURL:directionsURL];
}
else{
[[UIApplication sharedApplication] openURL:[NSURL
URLWithString:#"https://itunes.apple.com/us/app/google-maps/id585027354?mt=8"]];
}
Related
I'm using this code to redirect to iOS settings for the location:
NSURL *url = [NSURL URLWithString:#"App-Prefs:root=LOCATION_SERVICES"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:#{} completionHandler:nil];
}
But it is just redirecting to settings and not in location or bluetooth settings. Does anybody know if is any way to redirect to iOS location settings?
Thank you
Declare url as:
NSURL *url = [NSURL URLWithString:#"App-Prefs:root=LOCATION_SERVICES"];
thus:
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL: url];
}
NOTE:
The above approach should work for iOS 10.x and below (you could check: How to programmatically open the WIFI settings in Objective-C on iOS 10). However, the "app-prefs" URL scheme is not supported by Apple! prefs URLs are considered as private APIs, the only documented preference URL is the UIApplicationOpenSettingsURLString. Obviously, is has nothing to do with the used programming language; Related:
Swift 4 - IOS 11 / “Apps-prefs=root” function not working
IOS 11 / "Apps-prefs=root" function not working after update to Swift 3
Roughly speaking, you are not able to do such a navigation anymore on iOS 11.
First: Click on project name >> target>> Info >> url Types >> URL Schemes.
For example you can see the screenshot.
Then use the code:
-(IBAction)openSettingViewToEnableLocationService:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=LOCATION_SERVICES"]];
}
You can use UIApplicationOpenSettingsURLString. If your application uses location data or bluetooth you will see location and bluetooth settings there.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
How I show built in navigation options on google map iOS source and destination and navigation with voice or I have to implement google map api for this?
you can use the following code; it'll appear the selected location with drop annotation; and from google app you can navigate
https://developers.google.com/maps/documentation/ios-sdk/urlscheme
if ([[UIApplication sharedApplication] canOpenURL:[NSURL
URLWithString:#"comgooglemaps://"]])
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"comgooglemaps://?center=%f,%f&q=%f,%f",mosqueLocation.latitude,mosqueLocation.longitude, mosqueLocation.latitude,mosqueLocation.longitude]];
[[UIApplication sharedApplication] openURL:url];
} else {
NSLog(#"Can't use comgooglemaps://");
}
Is it possible to force through your application that it will open the web link in safari only not in native app like facebook, twitter or web view etc.
So far i searched found only this code that is used for opening the link
NSURL *url = [NSURL URLWithString:#"www.facebook.com"];
[[UIApplication sharedApplication] openURL:url];
But what can we paste in else there below?
if ([[UIApplication sharedApplication] canOpenURL:nsurl]){
[[UIApplication sharedApplication] openURL:nsurl];
}
else {
//Open the url as usual, but how?
}
Use http://facebook.com/ instead of www.facebook.com
this will force a link to open in Safari instead of native app*
NSURL *myURL = [NSURL URLWithString:#"http://facebook.com/"];
if ([[UIApplication sharedApplication] canOpenURL:myURL]) {
[[UIApplication sharedApplication] openURL:myURL];
}
You can use a webView to open any link of your choice.
I'm working on iOS application. Here is the code i used
NSURL *url = [NSURL URLWithString:#"fb://page/5718758966"];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
else
{
//Open the url as usual
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"https://facebook.com/5718758966"]];
}
As I mentioned, this code has worked to open Facebook app but shows blank page; my question is if there is an alternative link I can use that will both open the app and direct the user to this specific page, or is this simply a Facebook bug?
Thanks!
Instead of "fb://page/5718758966" try "fb://profile/5718758966" for your URL.
I was trying to open the Facebook app with particular Facebook page from my app with the following code:
NSURL *url = [NSURL URLWithString:#"http://www.facebook.com/pagename"];
[[UIApplication sharedApplication] openURL:url];
When I click on the button it opens the Facebook app but the required page doesn't load or show.
Is there any other way to open the Facebook app with particular Facebook page? Please correct me If I am doing something wrong.
Thanks in advance.
To open the facebook app directly you should do the following:
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString: #"fb://profile/PAGE_ID"]])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: #"fb://profile/PAGE_ID"]];
}
else
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: #"http://facebook.com/PAGE_NAME"]];
}
This is a solution including a fallback for web.
To determine your PAGE_ID you could use a service like this.