John Ramos John Ramos - 1 year ago 167
Swift Question

Background location tracking not working on physical device swift

I followed this tutorial ( to create an app that maps the user's location in the background. It asks to follow the user's location even when the app is closed, the user presses yes, and it tracks location in the background, updating every second or so. It works perfectly in the simulator, but sideloaded onto a physical iPhone 6, it stops checking the user's location in the background.

Answer Source

I solved this. If your background location tracking is working in the simulator but not on a physical phone running iOS 9 or later, it is fixed by adding this code:

if #available(iOS 9.0, *) {
            locationManager.allowsBackgroundLocationUpdates = true
        } else {
            // You don't need anything else on earlier versions.

Put this anywhere, maybe in your viewdidload.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download