1 Reply
      Latest reply on Oct 19, 2017 3:10 AM by AndrewJ
      sleipn1r Level 1 Level 1 (0 points)

        hi developer

         

         

        in my app use core location and get permission with

        this settings in viewController viewDidLoad (not in AppDelegate didFinishLaunchingWithOptions)

         

         

        ...

            locationManager = CLLocationManager()

            locationManager.delegate = self

         

         

        // and get request with

        locationManager!.requestAlwaysAuthorization()

         

         

         

         

        // and or

         

        // self.locationManager!.requestWhenInUseAuthorization()

            

        both are not working successful

         

         

        but no Message appear to grant access to User but the keys

         

         

        Privacy - Location When In Use Usage Description

        and

        Privacy - Location Always and When In Use Usage Description

         

         

        is set in my Info.plist

         

         

        now have print the status and the result from access

        from authorization status

         

         

        the result is "when in use"

        or

        "always"

         

         

         

         

        with this delegateMethod

         

         

         

         

            func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {

              

                 switch status {

              

                case .authorizedAlways:

                    print("always")

              

                    break

             

                case .authorizedWhenInUse:

                    print("when in use")

                  

                    break

                  

                case .denied:

                    print("denied")

                  

                    break

                  

                case .notDetermined:

                    print("notDetermined")

                    break

                  

                case .restricted:

                    print("restricted")

                  

                    break

                  

                  

                  

                }

              

            }

          

         

         

        following the the Message "when in use" or "always"

         

         

        Insufficient Location Services authorization. Monitoring will pause until appropriate authorization is granted.

         

         

        appear in console too.

         

         

        Xcode Verion 9.1 (9B46)

        iOS 11

        • Re: Core Location permission
          AndrewJ Level 1 Level 1 (0 points)

          Can you add your code for viewDidLoad() and class definition including variables?  How and where have you defined your locationManager variable - it should be at the class level rather than in the viewDidLoad() method.  It probably is, but I thought I'd ask.  Is this happening in the simulator? What about a physical device?  I have an issue with Location Services and timing that only seems to be a problem on the Simulator.   Have you tried a breakpoint on your print statements and then actually checking the Settings app and verifiying in Privacy that Location Services are enabled and in the app settings that authorisation is 'Always' or 'When in use' depending on how you requested it?  Finally, it might be worth erasing the simulator device and clearing out DerivedData.