简体   繁体   English

在iOS 6上通过我的应用获取当前用户的位置时遇到问题

[英]Have issue in get current user's location with my app on ios 6

My application is running fine on iOS 5, I get the normal user's location information. 我的应用程序在iOS 5上运行良好,我获得了普通用户的位置信息。 But when installing my app on iOS 6, my application can not get the user's location (I don't have the popup asking permission location, and in location services I don't have the icon of my app. Other apps like Instagram and Path have the icon of the app in the location services on iOS 6). 但是在iOS 6上安装我的应用程序时,我的应用程序无法获取用户的位置(我没有弹出询问权限位置,在位置服务中我没有应用程序的图标。其他应用程序,例如InstagramPath在iOS 6的位置服务中具有该应用程序的图标)。 When I use this code below to check this issue, NSlog shows: Unable to determine, possibly not available 当我在下面使用此代码检查此问题时, NSlog显示: Unable to determine, possibly not available

I don't understand why this is the case. 我不明白为什么会这样。 I've tried other apps like Instagram or Path. 我尝试了其他应用程序,例如Instagram或Path。 We still get the normal user's location. 我们仍然会获得普通用户的位置。 I studied iOS 6 change method delegate in CLLocationManagerDelegate , but I think that's not the reason because my application does not ask the permission to get the user's location. 我在CLLocationManagerDelegate研究了iOS 6更改方法委托,但我认为这不是原因,因为我的应用程序不要求获得用户位置的权限。

if ([CLLocationManager locationServicesEnabled]) {
        NSLog(@"Location Services Enabled");
        switch ([CLLocationManager authorizationStatus]) {
            case kCLAuthorizationStatusAuthorized:
                NSLog(@"We have access to location services");
                break;
            case kCLAuthorizationStatusDenied:
                NSLog(@"Location services denied by user");
                break;
            case kCLAuthorizationStatusRestricted:
                NSLog(@"Parental controls restrict location services");
                break;
            case kCLAuthorizationStatusNotDetermined:
                NSLog(@"Unable to determine, possibly not available");
                break;
            default:
                break;
        }
    }
    else {
        NSLog(@"Location Services Are Disabled");
    }

I have the same problem. 我也有同样的问题。 For my app this situation was generated because I check if locationServices is enabled and I start update location only if this is true ([self.locationManager startUpdatingLocation].) 对于我的应用程序,这种情况之所以产生,是因为我检查locationServices是否已启用,并且仅在为true时才开始更新位置([self.locationManager startUpdatingLocation]。)

+ (BOOL)locationServicesEnabled {
    if (([CLLocationManager locationServicesEnabled]) && ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized)) {
        return YES;
    } else {
        return NO;
    } 
}

[self.locationManager startUpdatingLocation] without the check looks fine, but it's possible to generate other problems. 没有检查的[self.locationManager startUpdatingLocation]看起来不错,但可能会产生其他问题。

I think your problem is, that you just check if location is available, but do not use it. 我认为您的问题是,您只是检查位置是否可用,而不使用它。 So iOS never asks for permission, because it isn't used. 因此,iOS从未请求许可,因为未使用它。 Your check is working fine! 您的支票运作良好!

Use a tutorial like this one and it will work. 使用教程像这一次 ,它会工作。 So did I resolve it for me! 我也为我解决了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过iphone应用程序中的代码获取用户的当前位置? - How to get the user's current location by code in iphone app? 使用IOS中的CLLocation获取用户当前位置 - Get User Current location using CLLocation in IOS 我在我的IOS应用程序中集成了google plus,但是我无法获取已登录的当前用户的电子邮件ID - I have integrated google plus in my IOS App ,But I am not able to get email Id of current user that is logged In 获取用户的当前位置/坐标 - Get User's Current Location / Coordinates iOS - 在应用启动时缩放到当前用户位置 - iOS - Zoom to the current user location at app start up 从App Store下载应用程序时,为什么我的应用程序不要求使用用户的当前位置? - Why doesn't my app ask to use the user's current location when it's downloaded from the App Store? 如何从iOS中获取用户的当前位置 - How can I get current location from user in iOS 如何在iOS 4.0 / 4.2中获取当前位置的经度和纬度? - How to get current location's longitude and latitude in iOS 4.0/4.2? iOS:有没有办法知道当前的iOS用户是否曾经使用过我的应用 - iOS: Is there a way to know if the current user of iOS ever used my app 获取用户在iOS上下载的应用的列表 - Get a list of user's downloaded app on iOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM