views:

666

answers:

1

from 1 week if my gps app fail to retrieve signal (eg: testing in my home) i don't receive any aler. i've setup my error notification in this way

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {      NSString *errorType = (error.code == kCLErrorDenied) ? 
@"Access Denied" : @"Errore sconosciuto"; 
UIAlertView *alert = [[UIAlertView alloc] 
                      initWithTitle:@"Errore recuperando la Location" 
                      message:errorType 
                      delegate:nil 
                      cancelButtonTitle:@"Okay" 
                      otherButtonTitles:nil]; 
[alert show]; 
[alert release]; 
} 

for what reason app do not retrieve data and do not show me the alert popup?

+4  A: 

because you're only checking One condition switch case you need to implement like

    - (void)locationManager: (CLLocationManager *)manager
           didFailWithError: (NSError *)error
    {
        [manager stopUpdatingLocation];
        NSLog(@"error%@",error);
        switch([error code])
        {
            case kCLErrorNetwork: // general, network-related error
            {
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"please check your network connection or that you are not in airplane mode" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
                [alert show];
                [alert release];
            }
                    break;
            case kCLErrorDenied:{
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"user has denied to use current Location " delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
                [alert show];
                [alert release];
            }
                    break;
            default:
            {
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"unknown network error" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
                [alert show];
                [alert release];
            }
                    break;
            }
        }

    }

There are still 2 more cases kCLErrorHeadingFailure and kCLErrorLocationUnknown but generally it won't be needed...

mihirpmehta
mhmmmm ok, i've understand your code, try but still not receiving popup message: i'll view on my screen latitude and longitude cached value and don't see the alert.ONE THING, i've add an mkreversegeocoder istance and now it will fail to retrieve my city (because i've no connettivity on my phone now). Can be usefoul this info?
zebra
ps in my consolle i retrieve only this log:2010-04-16 15:44:56.509 high[797:207] Error Domain=NSURLErrorDomain Code=-1009 UserInfo=0x178410 "no Internet connection"
zebra
your console suggest that you're having problem with your internetyou can try on different device or on simulator or on different wifi network... see if any of these works... that means your application is fine....
mihirpmehta
nono the error i log is correct, is from mkreversegeocoder not for cllocation;d, it's ok, at the moment my phone cannot be connected on internet, but i expect an error alert in getting position.
zebra
have you write [locationManager startUpdatingLocation]; in viewdidload or anywhere else...?
mihirpmehta
yes, in viewdidload i setup and start locationManager.
zebra
put break point here and see what exactly application is doing... because in any case default alert view should be pop up
mihirpmehta