定位服务无法在 iPad 上激活

发布于 2024-10-29 16:25:41 字数 890 浏览 4 评论 0原文

我正在开发一个使用定位服务的 iOS 应用程序。该应用程序在 iPhone(3GS 和 4)上运行良好,但在 iPad 上运行时不会请求位置服务。也就是说,系统不会要求用户启用位置服务,该应用程序也不会出现在“设置”应用程序的“位置服务”部分中。

我见过一些论坛帖子描述了类似的问题,但所有这些问题都是通过 iTunes(通过临时分发)在 iPad 上安装应用程序而不是通过 Xcode 运行它或通过重置位置警告来解决的。我在 iPad、iPad 2 和 iPad 模拟器上尝试了这两种解决方案,但均无济于事。

我们使用以下代码来启用位置服务更新。我们已经通过设备上调试和 NSLog 的放置来验证我们的代码正在运行。

- (id)init {
    [super init];

    if (clManager == nil) {
        clManager = [[CLLocationManager alloc] init];
    }
    clManager.delegate = self;

    [self startLocationMonitoring];

    return self;
}

- (BOOL)isLocationAvailable {
    return [CLLocationManager significantLocationChangeMonitoringAvailable];
}

- (void)startLocationMonitoring {
    if ([self isLocationAvailable]) {
        [clManager startMonitoringSignificantLocationChanges];
    } else {
        // handle lack of Location Services
    }
}

I am developing an iOS app which uses Location Services. The app works fine on iPhones (3GS and 4), but does not request locations services when run on the iPad. That is, the user is never asked to enable location services, nor does the app appear in Location Services section of the Settings app.

I have seen a few forum posts describing similar issues, but all of these were resolved by installing the app on the iPad through iTunes (via ad-hoc distribution) rather than running it through Xcode, or by resetting location warnings. I tried both of these solutions on an iPad, an iPad 2, and the iPad simulator, both to no avail.

We use the following code to enable Location Services updates. We have verified both by on-device debugging and placement of NSLogs that our code is getting run.

- (id)init {
    [super init];

    if (clManager == nil) {
        clManager = [[CLLocationManager alloc] init];
    }
    clManager.delegate = self;

    [self startLocationMonitoring];

    return self;
}

- (BOOL)isLocationAvailable {
    return [CLLocationManager significantLocationChangeMonitoringAvailable];
}

- (void)startLocationMonitoring {
    if ([self isLocationAvailable]) {
        [clManager startMonitoringSignificantLocationChanges];
    } else {
        // handle lack of Location Services
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清风疏影 2024-11-05 16:25:41

这可能无法回答您的问题,但可能会对某人有所帮助。 WiFi iPad 型号不支持重大位置更改(significantLocationChangeMonitoringAvailable 方法返回 NO),并且 startMonitoringSignificantLocationChanges 在这些型号上运行时似乎不执行任何操作– 它不会触发错误委托方法,也不会提出请求位置服务权限的蓝色气泡对话框。

This probably does not answer your question, but might help somebody. The WiFi iPad models don’t support significant location changes (the significantLocationChangeMonitoringAvailable method returns NO) and the startMonitoringSignificantLocationChanges seems to do nothing when running on these – it does not trigger the error delegate method nor it brings forward the blue bubble dialog asking for location services permission.

苏璃陌 2024-11-05 16:25:41

iPad 有 2 种型号(wifi 和 wifi+3G)。 http://www.apple.com/ipad/specs/

wifi型号没有A-GPS 支持。

如果您仔细阅读规范,您会发现 A-GPS 仅在 wifi+3G 型号上可用,也许您正在使用 wifi(仅)型号。

然而,如果路由器提供相同的功能,则通过 WIFI,iPad 可以检测位置,但您的情况似乎没有。

你可以在iPad2 wifi+3G版本上尝试你的应用程序,你会发现它运行得很好..!

iPad comes in 2 models (wifi and wifi+3G). http://www.apple.com/ipad/specs/

The wifi model does not have A-GPS support.

If yo go through the specification you will see that A-GPS is only available on wifi+3G model and perhaps you are using the wifi(only) model.

However, through WIFI, iPad can detect locations if router is providing the same which does not seems to be in your case.

You can try your app on iPad2 wifi+3G version and you will see that it runs just fine..!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文