本文轉載至http://www.cocoachina.com/bbs/read.php?tid-237825.html
1.在文件info.pilist 中
導入 NSLocationWhenInUseUsageDescription
//IOS8 新功能用戶開啓定位 2.appDelegate中帶入 #import <CoreLocation/CoreLocation.h> 3.加入下面的語句 CLLocationManager* location = [CLLocationManager new]; [location requestAlwaysAuthorization]; 再次運行軟件就能夠定位了。 緣由以下: scussion: * When +authorizationStatus == kCLAuthorizationStatusNotDetermined, * calling this method will trigger a prompt to request "always" * authorization from the user. If possible, perform this call in response * to direct user request for a location-based service so that the reason * for the prompt will be clear. Any authorization change as a result of * the prompt will be reflected via the usual delegate callback: * -locationManager:didChangeAuthorizationStatus:. * * If received, "always" authorization grants access to the user's * location via any CLLocationManager API, and grants access to * launch-capable monitoring API such as geofencing/region monitoring, * significante location visits, etc. Even if killed by the user, launch * events triggered by monitored regions or visit patterns will cause a * relaunch. * * "Always" authorization presents a significant risk to user privacy, and * as such requesting it is discouraged unless background launch behavior * is genuinely required. Do not call +requestAlwaysAuthorization unless * you think users will thank you for doing so. * * When +authorizationStatus != kCLAuthorizationStatusNotDetermined, (ie * generally after the first call) this method will do nothing. * * If the NSLocationAlwaysUsageDescription key is not specified in your * Info.plist, this method will do nothing, as your app will be assumed not * to support Always authorization. 大概意思就是說:IOS8 新增長了一個選項 ,若是要開啓定位這個隱私選項的話 須要在Pilist導入NSLocationWhenInUseUsageDescription,而後掉用 requestAlwaysAuthorization這個方法。 此方法執行後,當要執行定位功能的時候就會觸發一個詢問,詢問用戶是否使用定位功能,若是選擇是,則啓動定位功能,若是選擇否,則方法返回,下次還將繼續詢問用戶。 |
|