我的应用需要运行位置数据。我确保用户在登录前必须接受我的应用程序的位置服务。如果用户拒绝,它将阻止用户登录,直到用户授予应用程序使用位置服务的权限。
除了1个测试用户的设备外,一切运行良好。即使用户授予了应用程序位置服务权限,设备也根本无法获取位置数据。没有GPS图标出现。谷歌地图适用于用户的设备。我真的不确定这里发生了什么。看起来didUpdateToLocation
似乎根本没有在此用户的设备上调用。可能导致这个问题的原因是什么?
代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
[self getCurrentLocation];
...
}
- (void)getCurrentLocation {
if (nil == locationManager)
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
locationManager.distanceFilter = 100; // meters
[locationManager startMonitoringSignificantLocationChanges];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
[self setLatitude:[NSNumber numberWithFloat:currentLocation.coordinate.latitude]];
[self setLongitude:[NSNumber numberWithFloat:currentLocation.coordinate.longitude]];
if (loginController) {
[loginController validateSession];
loginController = nil;
}
}
}
答案 0 :(得分:1)
请检查以下表彰。有时候同样的问题发生在我身上。
完全卸载并重新安装并再次检查应用程序。
在iPhone设置中重置网络设置。
删除以前安装的应用程序并重新安装。
答案 1 :(得分:0)
您没有使用
- (void)startUpdatingLocation;
但你使用
- (void)startMonitoringSignificantLocationChanges;
由于您设置了所有过滤器,因此您可能希望使用第一个过滤器(startUpdatingLocation
)。
至于为什么单个用户的设备没有工作:startMonitoringSignificantLocationChanges不使用GPS来对用户的位置进行三角测量,因此将其与谷歌地图进行比较对你没有帮助。
有关这两种方法的详细信息,请参阅Apple的文档: Apple Doku