【问题标题】:How to handle "Don't Allow" for location manager?如何处理位置管理器的“不允许”?
【发布时间】:2010-02-25 10:46:39
【问题描述】:

我现在还没有想到这个。

到目前为止,每当设备要求我使用位置更新时,我都允许它。

但是当现在我不允许时,位置管理器会给我 kclErrorDenied 并且位置管理器在我重新启动应用程序之前无法再次启动。

所以我的问题是我应该向用户发送一条消息以重新启动应用程序,还是有解决方案重新开始使用位置管理器。

谢谢。

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.)"

【问题讨论】:

    标签: iphone cllocationmanager didfailwitherror


    【解决方案1】:

    实现- (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
        }
    }
    

    【讨论】:

    • 所以操作系统会问这个问题两次,如果我们不允许这两个时间我们必须重新启动应用程序,不是吗?
    • 是的,如果应用绝对需要当前位置。
    • 不...@willi 不正确。该应用程序将询问一次。第一次。您不能发起第二次许可请求。 Apple 要求您让用户知道(当他们单击不允许时)您的程序在没有地理位置的情况下将无法运行。如果需要,请告诉用户重新启动应用程序。如果您的应用可以在没有它的情况下运行,请继续使用该应用。无论如何,您必须让用户知道,否则 Apple 不会批准您的应用程序。 ps:他们做检查这个......所以做对了。
    • @Jann 我知道这是一篇很老的帖子,但如果你碰巧知道,该方法现在如何在 iphone 4 上处理多任务,因为关闭应用程序只会将其发送到后台,并且不会“重新启动”它吗?
    • @Ryan 不幸的是,没有简单的方法。 Apple 建议(并且我强烈将“建议”用斜体表示)如果您的应用在没有位置的情况下无法运行,那么您必须告诉用户到 Settings->General->Location Services 并打开您的应用使用位置服务的能力。否则,必须重新启动以重新请求该功能。另一种选择是简单地将UIApplicationExitsOnSuspend 键设置为true,这样您的应用程序就不会在后台运行,而是存在。这样应用程序将重新请求许可。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-03
    • 2012-06-19
    • 2021-11-25
    • 2013-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多