App crashing after getting location permission in iOS 9.3.1

662 views Asked by At

Hi

I want to get user location, code works first time getting location in didUpdateLocations. But after few second app crashing.

Crash is: enter image description here

Code I am using

import UIKit
import CoreLocation

class HomeViewController: UIViewController, UIScrollViewDelegate ,UICollectionViewDataSource, UICollectionViewDelegate, CLLocationManagerDelegate  { 

// Location Manager
var locationManager: CLLocationManager = CLLocationManager()

//MARK: Location related functions
func trackLocation(){
    // Set the delegate
    self.locationManager.delegate = self
    
    // Request location authorization
    self.locationManager.requestWhenInUseAuthorization()
    
    // Request a location update
    if #available(iOS 9.0, *) {
        self.locationManager.requestLocation()
    } else {
        // Fallback on earlier versions
    }

    // Start location updates
    self.locationManager.startUpdatingLocation()
    
}

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    if let location = locations.first {
        print("Found user's location: \(location)")
    }
}

func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
    print("Failed to find user's location: \(error.localizedDescription)")
}

Plist enter image description here

Please let me what I missed

1

There are 1 answers

0
Abdul Rauf On

Found the issue, we are using webengage for notification and event tracking, issue was in it.

When I check with removing of it, code work fine.

I have contacted with webengage support, they have fixed this issue, so

pod update

will fix this issue