Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSInternalInconsistencyException in CLLocation Manager setAllowsBackgroundLocationUpdates #393

Closed
msmollin opened this issue Nov 27, 2017 · 6 comments

Comments

@msmollin
Copy link
Member

msmollin commented Nov 27, 2017

Description

Reported by @nolispe280 in #390 -

"I have managed to load the SDK 1.1.1 via cocoapods (had to uninstall and reinstall it). I then added this code in the viewDidLoad function:

if self.locationManager.canEnableBackgroundLocationUpdates() {
        _ = self.locationManager.enableBackgroundLocationUpdates(forType: .other, desiredAccuracy: kCLLocationAccuracyBest, pausesLocationAutomatically: false)
      }

but still get the above error.
Does anyone else have this issue?"

@msmollin
Copy link
Member Author

I'll try to replicate this issue today.

Can you post what version of iOS you're testing on?

@nolispe280
Copy link

Great! I'm on iOS 11 coding on XCode 8

@msmollin
Copy link
Member Author

How are you deploying to iOS 11 with Xcode 8? Xcode 8 doesn't include the necessary symbols to deploy to iOS 11 devices.

@nolispe280
Copy link

Sorry I meant iOS 10.3.3 coding on Xcode 8.

@msmollin
Copy link
Member Author

Tested this scenario in a sample project and did not run into the issue mentioned.

However doing some research on it, that issue can arise when a developer doesn't add the correct plist entries for background modes and location privacy keys. I would double check your plist entries and make sure everything is set up correctly.

This also caused me to double check our sample app and noticed that technically our sample app is iOS 10 incompatible, so I opened #394 to track that.

Below is the code I used to test it. Perhaps it will give you some insight into what you're facing:

import UIKit
import Mapzen_ios_sdk
import CoreLocation

class ViewController: MZMapViewController {
  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    locationManager.requestAlwaysAuthorization()
    
  }

  override func authorizationDidSucceed() {
    super.authorizationDidSucceed()
    if locationManager.canEnableBackgroundLocationUpdates() {
      _ = locationManager.enableBackgroundLocationUpdates(forType: .other, desiredAccuracy: kCLLocationAccuracyBest, pausesLocationAutomatically: false)
    }
  }

  //Not necessary to override - only added so we can see this update in the background.
  override func locationDidUpdate(_ location: CLLocation) {
    print("Location did update!")
    super.locationDidUpdate(location)
  }
}

You'll also want to make sure you set your API key in your app delegate.

@nolispe280
Copy link

Indeed I needed to set the "Required Background Modes" to "location" in my plist file! But FYI, this is the first time I hear of this entry.
Thanks anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants