How to navigate to Location Services setting in an app - iphone

When a user whose location services are off, goes to a page that needs Location, a UIAlertView would appear, and at the bottom, there is a button named "Setting". When "setting" is clicked, it would jump to System Setting - Location Service.
What's the button action, or the URI for navigating to Location Services?

iOS doesn't provide an explicit way or URL to navigate to the Settings page.
As far as Location services are concerned, whenever an app tries to use location services, if the "Location Services" in the settings page is set to NO, iOS prompts an alertView for the user to enable (set YES) the option. On subsequent launches, if this option is set to YES, the user will not get this alertView.

All you need to do is to modify your Info.plist file to include location-services in your UIRequiredDeviceCapabilities entry

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=LOCATION_SERVICES"]];
You can do the above, but I don't know whether the App will pass through Apple's app review.If you know, please tell me.
Reference: jump to setting interface in iOS.

This will lead you to app setting page..Were you can change the Setting for you application including Location service..
NSURL *appSettings = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:appSettings];

Related

Re-enabling location services for iPhone app

I have been struggling with the location service request for my iPhone app. If the user says "Don't allow", I'm stuck in my "this app needs location services in order to work"...
All attempts to re-apply for location services have been fruitless, which several stacks here can testify to.
Then I read that the only way to re-enable the location services was to redirect the user to the location service settings using this :
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=LOCATION_SERVICES"]];
But even that doesn't seem to work (iPhone 4 and 4S, both on 5.1)
Is there really no other way, except telling the user to go to preferences and then guiding him through ? It seems so toe-twistingly bulky to me.
If the user turned the location service off, there is no other way then to tell the user to turn them on again.
You could try to redirect, but this is only possible on iOS 5.0. So you can do it like:
NSURL *prefsURL = [NSURL URLWithString:#"prefs:root=LOCATION_SERVICES"];
if ([[UIApplication sharedApplication] canOpenURL:prefsURL]) {
[[UIApplication sharedApplication] openURL:prefsURL];
} else {
// Can't redirect user to settings, display alert view
UIAlertView *alertView = ....
}

How add new window on button click and come back to previous window?

I have an application in which i have a button. I want to open a fb login url in browser and when i login successfully then i want to come back to my application. So problem is that how i fix that?
i use this code for.
-(IBAction)add_account:(id)sender{
switch ( ((UIButton*)sender).tag ){
case 0:
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://graph.facebook.com/oauth/authorize?client_id=xxxxxxxxxxxxx&redirect_uri=http://www.facebook.com/connect/login_success.html&type=user_agent&display=touch&scope=offline_access,publish_stream,read_stream"]];
break;
}
}
}
Thanks in advances...
You need to register an URL scheme for your own app. You can put the URL scheme in your app's project file on the "Info" tab, lower right is an "Add" button which allows to add an URL type. You can now edit that URL type in the list, especially filling out the identifier and more important the URL scheme. Assuming your URL scheme is "myapp":
Every URL starting with myapp:// now will be forwarded to your app. Now you simply have to implement application:openURL:sourceApplication:annotation in your application delegate which will handle all "myapp://" URLs. There you can, for example, extract information from the URL and show a specific view.
The myapp://-URL would of course go as redirect target in your original request.

iPhone - display the "location need to be available" dialog

Testing on the device (Iphone 4, IOS 4.2.1), when you use MapKit / CLLocationManager, there is a standard dialog that asks the user to enable the location settings, and propose a button to go to that settings.
If you click "OK", then this dialog never seems to appear again ?
How can I make it appear again programmaticaly to help the user to got to the correct settings view through that dialog ?
Well, it's not possible to programmatically bring up standard dialog asking user to allow your app using location services. It's all done by iOS.
However, you can always try starting location updates via startUpdatingLocation method on CLLocationManager instance. If location services are disabled, you'll get notified about error condition by delegate and then you can bring up the dialog asking user to go into Settings and enable location services for your app... See below code for filtering kCLErrorDenied.
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)inManager didFailWithError:(NSError *)inError{
if (inError.code == kCLErrorDenied) {
NSLog(#"Location manager denied access - kCLErrorDenied");
// your code to show UIAlertView telling user to re-enable location services
// for your app so they can benefit from extra functionality offered by app
}
}
Please note that you cannot launch Settings app via URL-scheme from your application.
UPDATE: starting from iOS5.1, you can not use the following method.
UPDATE: starting from iOS5, you can launch Settings from your application:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs://"]];

how to move moretab in iphone

in my applicaton,i have one directions tab in moretab.In directions tab, i displays the safari view through coding like this
NSString* url = #"http://maps.google.com/maps?saddr=33.68325,-117.834073&daddr=33.67425,-117.835073&dirflg=w";//[NSString stringWithFormat: #"http://maps.google.com/maps?q=%#",#"1101+E+Fletcher+Ave+Tampa+FL+33612"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
when click the directions tab it shows the safari browser.But my problem is after open the safari view, iam not able to move the more tab again. now what i want be done is ,when closing this safari view and reopen my application it directly shows the more tab not directions tab.How to do this.
Often times directing the user to Safari can be very confusing and some users don't understand how to come back. Consider using UIWebView instead for this since it stays inside your app and also provides you with the control that you are talking about now.
If you absolutely have to direct the user to safari I would take a look at this post that talk about how to catch the events of a user leaving your app and different states for that.

Return Back To Application From Browser

I'm implementing a website call on button touch(in iPhone), so my browser get called in that case and website get opened.
I'm using following code:
- (IBAction) websiteButtonTouched{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.google.com"]];
}
Now what I want is to COME BACK TO MY APPLICATION FROM BROWSER as In iPhone4.0 and Up the application remain running at background we only have to call that when browser quite...
Thanks In Advance.. :P
Why not create your own in-app browser? Just put a UIWebView inside a navigation controller then put an address bar and a search bar.
Please see this question:
iPhone - Open Application from Web Page
As for returning to application where you left off -- if the device supports backgrounding (iOS4+) and your backgrounded app wasn't unloaded (due to memory shortage), the app will return the point you left it.
However, you also have to handle the returning to correct point in app yourself, in the cases that the device doesn't support backgrounding, or app was unloaded due to memory shortage: you can do this by storing information about current state of the app before it exits.
This web page has some very nice flow charts which describe app backgrounding and foregrounding etc.:
http://www.cocoanetics.com/2010/07/understanding-ios-4-backgrounding-and-delegate-messaging