17

I haven't think of this yet now .

Till now whenever device was asking me use location update I was allowing it .

But when now I am not allowing then it the location manager gives me kclErrorDenied and the location manager can not start again until I restart the application .

So my question is that should I give a message to restart the app to the user or is there a solution to start working the location manager again .

thanks .

The Error :
ERROR,Time,288787555.078,Function,"void CLClientHandleDaemonDataRegistration(__CLClient*, const CLDaemonCommToClientRegistration*, const __CFDictionary*)",server did not accept client registration 1
WARNING,Time,288787555.108,Function,"void CLClientHandleDaemonInvalidation(__CFMessagePort*, void*)",client 1308.0 has been disconnected from daemon
 locationManager:didFailWithError:] [Line 244] Error Denied :Error Domain=kCLErrorDomain Code=1 "Operation could not be completed. (kCLErrorDomain error 1.)"
RedBlueThing
  • 42,006
  • 17
  • 96
  • 122
harshalb
  • 6,012
  • 13
  • 56
  • 92

1 Answers1

36

Implement - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error.

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
    NSMutableString *errorString = [[[NSMutableString alloc] init] autorelease];

    if ([error domain] == kCLErrorDomain) {

        // We handle CoreLocation-related errors here
    switch ([error code]) {
        // "Don't Allow" on two successive app launches is the same as saying "never allow". The user
        // can reset this for all apps by going to Settings > General > Reset > Reset Location Warnings.
        case kCLErrorDenied:
            //...
            break;
        case kCLErrorLocationUnknown:
            //...
            break;
        default:
            //...
            break;
        }
    } else {
        // We handle all non-CoreLocation errors here
    }
}
mt81
  • 3,288
  • 1
  • 26
  • 35
willi
  • 6,559
  • 4
  • 30
  • 27
  • so the os will ask this two times and if we disallow both the the time we have to restart the app , isn't it ? – harshalb Feb 25 '10 at 12:15
  • 1
    Yes, if the app absolutely needs the current location. – willi Feb 26 '10 at 00:03
  • 5
    No... @willi is not correct. The app will ask once. The first time. You cannot initiate a second request for permission. Apple requires you to let the user know (when they click Don't Allow) that your program will not work without Geo Location. If it is required, tell the user to relaunch the app. If your app can work without it, then go ahead and continue the app. Regardless, you must let the user know or Apple will not approve your app. ps: They *do* check this...so do it right. – Jann Feb 28 '10 at 08:16
  • @Jann I know this is a really old post, but if you happen to know, how would that method work with multitasking now on iphone 4, since closing the app only sends it to the background, and doesn't "restart" it? – Ryan Jun 03 '11 at 20:10
  • @Ryan unfortunately there is no simple way. Apple suggests (and i strongly italicize 'suggests') that if your app will not work without locations then you must tell the user to to to Settings->General->Location Services and turn your app's ability to use Location Services ON. Otherwise, it must be restarted to re-ask for that function. Another option is to simply use the `UIApplicationExitsOnSuspend` key set to true so your app does NOT background, instead it exists. This way the app will re-ask for permission. – Jann Jun 08 '11 at 18:58
  • Thank you for the feedback! I didn't know about the UIApplicationExitsOnSuspend key. I'll look into it. – Ryan Jun 23 '11 at 17:01