Bug 1923 - CLLocationManager.MonitoringFailed() not called when Location Services are turned off
Summary: CLLocationManager.MonitoringFailed() not called when Location Services are tu...
Status: RESOLVED FEATURE
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-11-07 20:08 UTC by Andrew Young
Modified: 2011-11-09 16:52 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
sample app (5.72 KB, application/zip)
2011-11-07 20:09 UTC, Andrew Young
Details
sample app #2 (8.90 KB, application/zip)
2011-11-09 15:48 UTC, Andrew Young
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FEATURE

Description Andrew Young 2011-11-07 20:08:45 UTC
Apple's iOS documentation states that locationManager:didFailWithError: should be called if user denies location services to your app.

"If the user denies your application’s use of the location service, this method reports a kCLErrorDenied error. Upon receiving such an error, you should stop the location service."

http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLLocationManagerDelegate_Protocol/CLLocationManagerDelegate/CLLocationManagerDelegate.html#//apple_ref/doc/uid/TP40007124

MonoTouch is not calling CLLocationManager.MonitoringFailed() when location services are turn off for the app.

Run the attached sample project on your device. Turn off location services and notice that there is no console write.
Comment 1 Andrew Young 2011-11-07 20:09:37 UTC
Created attachment 838 [details]
sample app
Comment 2 Sebastien Pouliot 2011-11-08 08:40:54 UTC
You're using the wrong event. 

"locationManager:didFailWithError:" maps to "Failed" while
"locationManager:monitoringDidFailForRegion:withError:" maps to "MonitoringFailed"


Try:

		_manager.Failed += Handle_managerFailed;

...

		void Handle_managerFailed (object sender, NSErrorEventArgs e)
		{
			Console.Write ("Location refused");
		}

and it should works like expected.
Comment 3 Andrew Young 2011-11-08 12:39:55 UTC
Oh. Wow. I'm completely embarrassed now. Thank you.
Comment 4 Sebastien Pouliot 2011-11-08 13:08:31 UTC
no problem :) 

Miguel's rosetta [1] is very helpful to find the "right" mapping between selectors and methods (if you know the former). MD code completion is nice but sometimes there's too many choice and similar names.

[1] http://tirania.org/tmp/rosetta.html
Comment 5 Andrew Young 2011-11-09 15:48:36 UTC
Created attachment 857 [details]
sample app #2

Ok. I think this is a legitimate bug this time. I have attached a new sample app #2 that has the suggested changes from Sebastien.

Steps to reproduce.

1. on iPhone, go to Settings > General > Reset > Reset Location Warnings
2. on iPhone go to Settings > Location Services > Turn it off completely for the phone just to be sure
3. build and deploy app
4. when prompted to turn on location services hit "Cancel"
5. verify that nothing gets printed to console
Comment 6 Andrew Young 2011-11-09 15:51:13 UTC
If the bug doesn't present itself the first time, uninstall, then reinstall the app. Follow the steps again.
Comment 7 Sebastien Pouliot 2011-11-09 16:52:47 UTC
Andrew, this bug is closed and won't show on anyone's radar (except mine since I'm on c.c.).
Please always open a new bug report unless you're 100% sure it's a regression (same test case, same error, new version). Thanks!