if ([CLLocationManager locationServicesEnabled]) { #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1 // As of iOS 8, apps must explicitly request location services permissions. INTULocationManager supports both levels, "Always" and "When In Use". // INTULocationManager determines which level of permissions to request based on which description key is present in your app's Info.plist // If you provide values for both description keys, the more permissive "Always" level is requested. if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1 && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) { BOOL hasAlwaysKey = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"] != nil; BOOL hasWhenInUseKey = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"] != nil; if (hasAlwaysKey) { [self.m_locationManager requestAlwaysAuthorization]; } else if (hasWhenInUseKey) { [self.m_locationManager requestWhenInUseAuthorization]; } else { // At least one of the keys NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription MUST be present in the Info.plist file to use location services on iOS 8+. NSAssert(hasAlwaysKey || hasWhenInUseKey, @"To use location services in iOS 8+, your Info.plist must provide a value for either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription."); } } #endif /* __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1 */ [self.m_locationManager startUpdatingLocation];
上述代碼添加在
成都創(chuàng)新互聯(lián)公司長期為數(shù)千家客戶提供的網(wǎng)站建設(shè)服務(wù),團隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為涼州企業(yè)提供專業(yè)的成都網(wǎng)站制作、做網(wǎng)站,涼州網(wǎng)站改版等技術(shù)服務(wù)。擁有10余年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。
[self.m_locationManager startUpdatingLocation];
之前,
除了上述代碼,還需要在info.plist中添加: