Location Services not working in iOS 8

前端 未结 26 2024
滥情空心
滥情空心 2020-11-21 10:23

My app that worked fine on iOS 7 doesn\'t work with the iOS 8 SDK.

CLLocationManager doesn\'t return a location, and I don\'t see my app under

26条回答
  •  梦如初夏
    2020-11-21 10:26

    In iOS 8 you need to do two extra things to get location working: Add a key to your Info.plist and request authorization from the location manager asking it to start

    info.plist:

    NSLocationUsageDescription
    I need location
    NSLocationAlwaysUsageDescription
    I need location
    NSLocationWhenInUseUsageDescription
    I need location
    

    Add this to your code

    if (IS_OS_8_OR_LATER)
    {
        [locationmanager requestWhenInUseAuthorization];
    
        [locationmanager requestAlwaysAuthorization];
    }
    

提交回复
热议问题